import { spawnSync } from 'node:child_process' const candidates = process.platform === 'win32' ? [ ['py', ['-3']], ['python3', []], ['python', []], ] : [ ['python3', []], ['python', []], ] for (const [command, prefix] of candidates) { const result = spawnSync(command, [...prefix, ...process.argv.slice(2)], { stdio: 'inherit', }) if (result.error?.code === 'ENOENT') continue process.exit(result.status ?? 1) } console.error('Python 3 was not found. Install Python 3 and retry.') process.exit(1)