Download ui/cron/pythonPath.ts from michaelu0826/ai_toolkit_code: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/datasets/michaelu0826/ai_toolkit_code/resolve/main/ui/cron/pythonPath.ts
- Command line
-
hf download hf://datasets/michaelu0826/ai_toolkit_code/ui/cron/pythonPath.ts
-
curl -L -o pythonPath.ts https://huggingface.co/datasets/michaelu0826/ai_toolkit_code/resolve/main/ui/cron/pythonPath.ts
855 Bytes
| 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'; | |
| }; | |