File size: 855 Bytes
d02c2a6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import path from 'path';
import fs from 'fs';
import { TOOLKIT_ROOT } from './paths';
const isWindows = process.platform === 'win32';
// Shared resolver used by both the cron worker and Next.js API routes
// so the Python interpreter is configured in exactly one place.
export const resolvePythonPath = (): string => {
const candidates: string[] = [];
if (isWindows) {
candidates.push(path.join(TOOLKIT_ROOT, '.venv', 'Scripts', 'python.exe'));
candidates.push(path.join(TOOLKIT_ROOT, 'venv', 'Scripts', 'python.exe'));
} else {
candidates.push(path.join(TOOLKIT_ROOT, '.venv', 'bin', 'python'));
candidates.push(path.join(TOOLKIT_ROOT, 'venv', 'bin', 'python'));
}
for (const candidate of candidates) {
if (fs.existsSync(candidate)) {
return candidate;
}
}
return isWindows ? 'python.exe' : 'python3';
};
|