import { existsSync } from "node:fs"; import path from "node:path"; export function pythonCandidates(cwd: string, packageRoot: string, platform = process.platform): string[] { const pathApi = platform === "win32" ? path.win32 : path.posix; const executable = platform === "win32" ? pathApi.join("Scripts", "python.exe") : pathApi.join("bin", "python"); return [ pathApi.join(cwd, ".venv", executable), pathApi.join(packageRoot, ".venv", executable), ]; } export function pythonBin(cwd: string, packageRoot: string): string { return pythonCandidates(cwd, packageRoot).find((candidate) => existsSync(candidate)) ?? (process.platform === "win32" ? "python" : "python3"); }