server: use fixed python3.11. install custom pythons into module path.

This commit is contained in:
Koushik Dutta
2024-03-18 10:04:47 -07:00
parent 544570d435
commit 3356777021
4 changed files with 22 additions and 14 deletions

View File

@@ -23,6 +23,8 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
}
}
static pythonInstalls = new Map<string, Promise<string>>();
serializer: ReturnType<typeof createRpcDuplexSerializer>;
peerin: Writable;
peerout: Readable;
@@ -126,18 +128,24 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
(this.worker.stdio[4] as Readable).pipe(peerout);
};
const py = new PortablePython(pluginPythonVersion, path.dirname(options.unzippedPath));
const py = new PortablePython(pluginPythonVersion);
if (fs.existsSync(py.executablePath)) {
pythonPath = py.executablePath;
finishSetup();
}
else {
this.pythonInstallationComplete = false;
installScryptedServerRequirements(pluginPythonVersion, path.dirname(options.unzippedPath))
.then(executablePath => {
pythonPath = executablePath;
finishSetup();
})
let install = PythonRuntimeWorker.pythonInstalls.get(pluginPythonVersion);
if (!install) {
install = installScryptedServerRequirements(pluginPythonVersion);
install.catch(() => { });
PythonRuntimeWorker.pythonInstalls.set(pluginPythonVersion, install);
}
install.then(executablePath => {
pythonPath = executablePath;
finishSetup();
})
.catch(() => {
process.nextTick(() => {
this.emit('error', new Error('Failed to install portable python.'));