MCPcopy Index your code
hub / github.com/AutoForgeAI/autoforge / tryPythonCandidate

Function tryPythonCandidate

lib/cli.js:92–116  ·  view source on GitHub ↗

* Try a single Python candidate. Returns { exe, version } or null. * `candidate` is either a bare name or an array of args (e.g. ['py', '-3']).

(candidate)

Source from the content-addressed store, hash-verified

90 * `candidate` is either a bare name or an array of args (e.g. ['py', '-3']).
91 */
92function tryPythonCandidate(candidate) {
93 const args = Array.isArray(candidate) ? candidate : [candidate];
94 const exe = args[0];
95 const extraArgs = args.slice(1);
96
97 try {
98 const out = execFileSync(exe, [...extraArgs, '--version'], {
99 encoding: 'utf8',
100 timeout: 10_000,
101 stdio: ['pipe', 'pipe', 'pipe'],
102 });
103
104 const ver = parsePythonVersion(out);
105 if (!ver) return null;
106
107 // Require 3.11+
108 if (ver.major < 3 || (ver.major === 3 && ver.minor < 11)) {
109 return { exe: args.join(' '), version: ver, tooOld: true };
110 }
111
112 return { exe: args.join(' '), version: ver, tooOld: false };
113 } catch {
114 return null;
115 }
116}
117
118// ---------------------------------------------------------------------------
119// Python detection

Callers 1

findPythonFunction · 0.85

Calls 1

parsePythonVersionFunction · 0.85

Tested by

no test coverage detected