Files
scrypted/server/bin/postinstall
2024-03-09 07:43:23 -08:00

25 lines
690 B
JavaScript

#!/usr/bin/env node
const child_process = require('child_process');
const { PortablePython } = require('py')
const { once } = require('events');
let python;
async function pipInstall(pkg) {
const cp = child_process.spawn(python, ['-m', 'pip', 'install', pkg], { stdio: 'inherit' });
const [exitCode] = await once(cp, 'exit');
if (exitCode)
throw new Error('non-zero exit code: ' + exitCode);
}
async function installScryptedServerRequirements() {
const py = new PortablePython("3.9");
await py.install();
python = py.executablePath;
await pipInstall('debugpy');
await pipInstall('psutil').catch(() => {});
}
installScryptedServerRequirements();