Merge branch 'main' of github.com:koush/scrypted

This commit is contained in:
Koushik Dutta
2024-08-13 20:13:11 -07:00
3 changed files with 7 additions and 5 deletions

View File

@@ -1,2 +1,2 @@
export declare declare const version: string;
export declare async function installScryptedServerRequirements(version?: string, dest?: string): Promise<string>;
export declare async function installScryptedServerRequirements(version?: string, dest?: string, options?: any): Promise<string>;

View File

@@ -13,8 +13,8 @@ async function pipInstall(python, pkg) {
throw new Error('non-zero exit code: ' + exitCode);
}
module.exports.installScryptedServerRequirements = async function installScryptedServerRequirements(version, dest) {
const py = new PortablePython(version || require('./packaged-python').version, dest);
module.exports.installScryptedServerRequirements = async function installScryptedServerRequirements(version, dest, options) {
const py = new PortablePython(version || require('./packaged-python').version, dest, options);
await py.install();
let python = py.executablePath;

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) {