MCPcopy Create free account
hub / github.com/beita6969/ScienceClaw / resolvePythonExecutablePath

Function resolvePythonExecutablePath

src/hooks/gmail-setup-utils.ts:118–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116}
117
118export async function resolvePythonExecutablePath(): Promise<string | undefined> {
119 if (cachedPythonPath !== undefined) {
120 return cachedPythonPath ?? undefined;
121 }
122 const candidates = findExecutablesOnPath(["python3", "python"]);
123 for (const candidate of candidates) {
124 const res = await runCommandWithTimeout(
125 [candidate, "-c", "import os, sys; print(os.path.realpath(sys.executable))"],
126 { timeoutMs: 2_000 },
127 );
128 if (res.code !== 0) {
129 continue;
130 }
131 const resolved = res.stdout.trim().split(/\s+/)[0];
132 if (!resolved) {
133 continue;
134 }
135 try {
136 fs.accessSync(resolved, fs.constants.X_OK);
137 cachedPythonPath = resolved;
138 return resolved;
139 } catch {
140 // keep scanning
141 }
142 }
143 cachedPythonPath = null;
144 return undefined;
145}
146
147async function gcloudEnv(): Promise<NodeJS.ProcessEnv | undefined> {
148 if (process.env.CLOUDSDK_PYTHON) {

Callers 2

gcloudEnvFunction · 0.85

Calls 2

findExecutablesOnPathFunction · 0.85
runCommandWithTimeoutFunction · 0.85

Tested by

no test coverage detected