({
pythonBin,
filesOrDirectories,
env,
excludeRegex,
}: CompileAllOptions)
| 57 | * Failures are logged but not surfaced to the user |
| 58 | */ |
| 59 | export async function runCompileAll({ |
| 60 | pythonBin, |
| 61 | filesOrDirectories, |
| 62 | env, |
| 63 | excludeRegex, |
| 64 | }: CompileAllOptions): Promise<void> { |
| 65 | if (filesOrDirectories.length === 0) return; |
| 66 | |
| 67 | const args = [ |
| 68 | '-m', |
| 69 | 'compileall', |
| 70 | '-q', |
| 71 | '-j', |
| 72 | '0', |
| 73 | '-f', |
| 74 | '--invalidation-mode', |
| 75 | 'unchecked-hash', |
| 76 | ...(excludeRegex ? ['-x', excludeRegex] : []), |
| 77 | ...filesOrDirectories, |
| 78 | ]; |
| 79 | |
| 80 | try { |
| 81 | await execa(pythonBin, args, { env: env || process.env }); |
| 82 | } catch (err) { |
| 83 | debug(`compileall error details: ${JSON.stringify(err)}`); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Derive the expected `__pycache__` `.pyc` path for a given `.py` source |
no test coverage detected