diff --git a/server/package-lock.json b/server/package-lock.json index 2df71fb62..8eb30a51e 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/server", - "version": "0.115.12", + "version": "0.115.15", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@scrypted/server", - "version": "0.115.12", + "version": "0.115.15", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/server/python/plugin_remote.py b/server/python/plugin_remote.py index da8580711..4043b83cc 100644 --- a/server/python/plugin_remote.py +++ b/server/python/plugin_remote.py @@ -800,12 +800,7 @@ class PluginRemote: print("requirements.txt (up to date)") print(str_requirements) - - # use the zip path first - sys.path.insert(0, zipPath) - if not debug: - # needed for binary extensions - sys.path.insert(0, plugin_zip_paths.get("unzipped_path")) + sys.path.insert(0, plugin_zip_paths.get("unzipped_path")) sys.path.insert(0, pip_target) self.systemManager = SystemManager(self.api, self.systemState) @@ -896,6 +891,11 @@ class PluginRemote: zip, self, self.systemManager, self.deviceManager, self.mediaManager ) + # plugin embedded files are treated as the working directory, chdir to that. + fsPath = os.path.join(plugin_zip_paths.get("unzipped_path"), "fs") + os.makedirs(fsPath, exist_ok=True) + os.chdir(fsPath) + if not forkMain: from main import create_scrypted_plugin # type: ignore diff --git a/server/src/plugin/runtime/node-worker-common.ts b/server/src/plugin/runtime/node-worker-common.ts index b15f54477..c65c1d1ab 100644 --- a/server/src/plugin/runtime/node-worker-common.ts +++ b/server/src/plugin/runtime/node-worker-common.ts @@ -93,10 +93,6 @@ export function extractZip(pluginVolume: string, h: string, zipBuffer: Buffer) { fs.writeFileSync(path.join(zipDirTmp, zipFilename), zipBuffer); const admZip = new AdmZip(zipBuffer); admZip.extractAllTo(path.join(zipDirTmp, 'unzipped'), true); - const fsPath = path.join(zipDirTmp, 'unzipped', 'fs'); - fs.mkdirSync(fsPath, { - recursive: true, - }); fs.renameSync(zipDirTmp, zipDir); return { diff --git a/server/src/plugin/runtime/python-worker.ts b/server/src/plugin/runtime/python-worker.ts index 917bc1869..4aa23cd93 100644 --- a/server/src/plugin/runtime/python-worker.ts +++ b/server/src/plugin/runtime/python-worker.ts @@ -96,10 +96,8 @@ export class PythonRuntimeWorker extends ChildProcessWorker { const setup = () => { const types = require.resolve('@scrypted/types'); const PYTHONPATH = types.substring(0, types.indexOf('types') + 'types'.length); - const fsDir = path.join(options.unzippedPath, 'fs'); - fs.mkdirSync(fsDir, { recursive: true }); this.worker = child_process.spawn(pythonPath, args, { - cwd: fsDir, + cwd: options.unzippedPath, // stdin, stdout, stderr, peer in, peer out stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'], env: Object.assign({