MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / getSysExecutable

Function getSysExecutable

src/python/pythonUtils.ts:172–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

170 * @returns The Python executable path if successful, or null if failed.
171 */
172export async function getSysExecutable(): Promise<string | null> {
173 if (process.platform === 'win32') {
174 // Windows: Try 'where python' first to avoid Microsoft Store stubs
175 const whereResult = await tryWindowsWhere();
176 if (whereResult) {
177 return whereResult;
178 }
179
180 // Then try py launcher commands (removing python3 as it's uncommon on Windows)
181 const sysResult = await tryPythonCommands(['py', 'py -3']);
182 if (sysResult) {
183 return sysResult;
184 }
185
186 // Final fallback to direct python command
187 return await tryDirectCommands(['python']);
188 } else {
189 // Unix: Standard python3/python detection
190 return await tryPythonCommands(['python3', 'python']);
191 }
192}
193
194/**
195 * Attempts to validate a Python executable path.

Callers 1

validatePythonPathFunction · 0.70

Calls 3

tryPythonCommandsFunction · 0.85
tryWindowsWhereFunction · 0.70
tryDirectCommandsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…