@@ -5,6 +5,7 @@ import { Result, err, isErr, ok } from "../functional/result"
55import { getProjectRoot } from "../common/utilities"
66import { execFile } from "child_process"
77import { promisify } from "util"
8+ import { isPythonModuleInstalled } from "../python"
89
910
1011export type sqlmesh_exec = {
@@ -22,39 +23,7 @@ export type sqlmesh_exec = {
2223export const is_tcloud_installed = async ( ) : Promise <
2324 Result < boolean , string >
2425> => {
25- const interpreterDetails = await getInterpreterDetails ( )
26- if ( ! interpreterDetails . path ) {
27- return err ( "No Python interpreter found" )
28- }
29- traceVerbose (
30- `Using interpreter from Python extension: ${ interpreterDetails . path . join (
31- " "
32- ) } `
33- )
34-
35- const pythonPath = interpreterDetails . path [ 0 ]
36- const checkScript = `
37- import sys
38- if sys.version_info >= (3, 12):
39- from importlib import metadata
40- else:
41- import importlib_metadata as metadata
42-
43- try:
44- metadata.version('tcloud')
45- print("true")
46- except metadata.PackageNotFoundError:
47- print("false")
48- `
49- try {
50- const execFileAsync = promisify ( execFile )
51- traceVerbose ( `Checking tcloud installation with script: ${ checkScript } ` )
52- const { stdout } = await execFileAsync ( pythonPath , [ "-c" , checkScript ] )
53- traceVerbose ( `tcloud installation check result: ${ stdout . trim ( ) } ` )
54- return ok ( stdout . trim ( ) === "true" )
55- } catch ( error ) {
56- return err ( `Failed to check tcloud installation: ${ error } ` )
57- }
26+ return isPythonModuleInstalled ( "tcloud" )
5827}
5928
6029/**
0 commit comments