server: allow plugins to customize python installs (#1542)

* server: allow plugins to customize python installs

* move options inside pythonVersion
This commit is contained in:
Brett Jia
2024-08-13 21:18:39 -04:00
committed by GitHub
parent 407f573a29
commit 0bc6fadb23
3 changed files with 7 additions and 5 deletions

View File

@@ -116,6 +116,8 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
if (process.env.SCRYPTED_PORTABLE_PYTHON && !pluginPythonVersion)
pluginPythonVersion = packagedPythonVersion;
let portablePythonOptions = options.packageJson.scrypted.pythonVersion?.options?.[os.platform()]?.[os.arch()] || options.packageJson.scrypted.pythonVersion?.options?.default || {};
// if the plugin requests a specific python, then install it via portable python
if (!pluginPythonVersion) {
setup();
@@ -148,7 +150,7 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
const pyPath = path.join(getPluginVolume(pluginId), 'py');
const portableInstallPath = path.join(pyPath, pyVersion);
const py = new PortablePython(pluginPythonVersion, portableInstallPath);
const py = new PortablePython(pluginPythonVersion, portableInstallPath, portablePythonOptions);
if (fs.existsSync(py.executablePath)) {
pythonPath = py.executablePath;
finishSetup();
@@ -158,7 +160,7 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
try {
this.pythonInstallationComplete = false;
await fs.promises.rm(pyPath, { recursive: true, force: true }).catch(() => { });
pythonPath = await installScryptedServerRequirements(pluginPythonVersion, portableInstallPath);
pythonPath = await installScryptedServerRequirements(pluginPythonVersion, portableInstallPath, portablePythonOptions);
finishSetup();
}
catch (e) {