@scrypted/server 0.94.37 → 0.94.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/postinstall
CHANGED
@@ -1,2 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
2
|
+
// install portable python if the SCRYPTED_PYTHON_PATH variable is unset.
|
3
|
+
// this variable will be unset for docker and lxc environments.
|
4
|
+
if (!process.env.SCRYPTED_PYTHON_PATH) {
|
5
|
+
require('./packaged-python').installScryptedServerRequirements();
|
6
|
+
}
|
@@ -16,14 +16,16 @@ const plugin_volume_1 = require("../plugin-volume");
|
|
16
16
|
const child_process_worker_1 = require("./child-process-worker");
|
17
17
|
class PythonRuntimeWorker extends child_process_worker_1.ChildProcessWorker {
|
18
18
|
static {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
if (!fs_1.default.existsSync(process.env.SCRYPTED_PYTHON_PATH)) {
|
20
|
+
try {
|
21
|
+
const py = new py_1.PortablePython(packaged_python_1.version);
|
22
|
+
const portablePython = py.executablePath;
|
23
|
+
// is this possible?
|
24
|
+
if (fs_1.default.existsSync(portablePython))
|
25
|
+
process.env.SCRYPTED_PYTHON_PATH = portablePython;
|
26
|
+
}
|
27
|
+
catch (e) {
|
28
|
+
}
|
27
29
|
}
|
28
30
|
}
|
29
31
|
serializer;
|
@@ -95,46 +97,55 @@ class PythonRuntimeWorker extends child_process_worker_1.ChildProcessWorker {
|
|
95
97
|
this.worker.stderr.pipe(this.stderr);
|
96
98
|
};
|
97
99
|
// if the plugin requests a specific python, then install it via portable python
|
98
|
-
if (pluginPythonVersion) {
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
this.worker.stdio[4].pipe(peerout);
|
105
|
-
};
|
106
|
-
const pyVersion = require('py/package.json').version;
|
107
|
-
const pyPath = path_1.default.join((0, plugin_volume_1.getPluginVolume)(pluginId), 'py');
|
108
|
-
const portableInstallPath = path_1.default.join(pyPath, pyVersion);
|
109
|
-
const py = new py_1.PortablePython(pluginPythonVersion, portableInstallPath);
|
110
|
-
if (fs_1.default.existsSync(py.executablePath)) {
|
111
|
-
pythonPath = py.executablePath;
|
112
|
-
finishSetup();
|
113
|
-
}
|
114
|
-
else {
|
115
|
-
(async () => {
|
116
|
-
try {
|
117
|
-
this.pythonInstallationComplete = false;
|
118
|
-
await fs_1.default.promises.rm(pyPath, { recursive: true, force: true }).catch(() => { });
|
119
|
-
pythonPath = await (0, packaged_python_1.installScryptedServerRequirements)(pluginPythonVersion, portableInstallPath);
|
120
|
-
finishSetup();
|
121
|
-
}
|
122
|
-
catch (e) {
|
123
|
-
process.nextTick(() => {
|
124
|
-
this.emit('error', new Error('Failed to install portable python.'));
|
125
|
-
});
|
126
|
-
}
|
127
|
-
finally {
|
128
|
-
this.pythonInstallationComplete = true;
|
129
|
-
}
|
130
|
-
})();
|
131
|
-
}
|
100
|
+
if (!pluginPythonVersion) {
|
101
|
+
setup();
|
102
|
+
this.peerin = this.worker.stdio[3];
|
103
|
+
this.peerout = this.worker.stdio[4];
|
104
|
+
this.setupWorker();
|
105
|
+
return;
|
132
106
|
}
|
133
|
-
|
107
|
+
const strippedPythonVersion = pluginPythonVersion.replace('.', '');
|
108
|
+
const envPython = process.env[`SCRYPTED_PYTHON${strippedPythonVersion}_PATH`];
|
109
|
+
if (fs_1.default.existsSync(envPython)) {
|
110
|
+
pythonPath = envPython;
|
134
111
|
setup();
|
135
112
|
this.peerin = this.worker.stdio[3];
|
136
113
|
this.peerout = this.worker.stdio[4];
|
137
114
|
this.setupWorker();
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
const peerin = this.peerin = new stream_1.PassThrough();
|
118
|
+
const peerout = this.peerout = new stream_1.PassThrough();
|
119
|
+
const finishSetup = () => {
|
120
|
+
setup();
|
121
|
+
peerin.pipe(this.worker.stdio[3]);
|
122
|
+
this.worker.stdio[4].pipe(peerout);
|
123
|
+
};
|
124
|
+
const pyVersion = require('py/package.json').version;
|
125
|
+
const pyPath = path_1.default.join((0, plugin_volume_1.getPluginVolume)(pluginId), 'py');
|
126
|
+
const portableInstallPath = path_1.default.join(pyPath, pyVersion);
|
127
|
+
const py = new py_1.PortablePython(pluginPythonVersion, portableInstallPath);
|
128
|
+
if (fs_1.default.existsSync(py.executablePath)) {
|
129
|
+
pythonPath = py.executablePath;
|
130
|
+
finishSetup();
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
(async () => {
|
134
|
+
try {
|
135
|
+
this.pythonInstallationComplete = false;
|
136
|
+
await fs_1.default.promises.rm(pyPath, { recursive: true, force: true }).catch(() => { });
|
137
|
+
pythonPath = await (0, packaged_python_1.installScryptedServerRequirements)(pluginPythonVersion, portableInstallPath);
|
138
|
+
finishSetup();
|
139
|
+
}
|
140
|
+
catch (e) {
|
141
|
+
process.nextTick(() => {
|
142
|
+
this.emit('error', new Error('Failed to install portable python.'));
|
143
|
+
});
|
144
|
+
}
|
145
|
+
finally {
|
146
|
+
this.pythonInstallationComplete = true;
|
147
|
+
}
|
148
|
+
})();
|
138
149
|
}
|
139
150
|
}
|
140
151
|
setupRpcPeer(peer) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"python-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/python-worker.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA0C;AAC1C,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,2BAAoC;AACpC,mCAAyD;AACzD,kEAAmH;AAEnH,yDAAiE;AACjE,oDAAmD;AACnD,iEAA4D;AAG5D,MAAa,mBAAoB,SAAQ,yCAAkB;IACvD;QACI,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"python-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/python-worker.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA0C;AAC1C,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;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;YACxB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACtB,UAAU,CAAC,cAAc,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YACrB,UAAU,CAAC,cAAc,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED,IAAI,CAAC,OAAmB,EAAE,MAA2B,EAAE,oBAA0B;QAC7E,IAAI,CAAC;YACD,IAAI,IAAI,CAAC,0BAA0B,IAAI,CAAC,IAAI,CAAC,MAAM;gBAC/C,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACrD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACP,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AA7LD,kDA6LC"}
|
package/package.json
CHANGED
@@ -13,14 +13,16 @@ import { RuntimeWorkerOptions } from "./runtime-worker";
|
|
13
13
|
|
14
14
|
export class PythonRuntimeWorker extends ChildProcessWorker {
|
15
15
|
static {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
if (!fs.existsSync(process.env.SCRYPTED_PYTHON_PATH)) {
|
17
|
+
try {
|
18
|
+
const py = new PortablePython(packagedPythonVersion);
|
19
|
+
const portablePython = py.executablePath;
|
20
|
+
// is this possible?
|
21
|
+
if (fs.existsSync(portablePython))
|
22
|
+
process.env.SCRYPTED_PYTHON_PATH = portablePython;
|
23
|
+
}
|
24
|
+
catch (e) {
|
25
|
+
}
|
24
26
|
}
|
25
27
|
}
|
26
28
|
|
@@ -85,7 +87,7 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
|
|
85
87
|
}
|
86
88
|
|
87
89
|
let pythonPath = process.env.SCRYPTED_PYTHON_PATH;
|
88
|
-
const pluginPythonVersion = options.packageJson.scrypted.pythonVersion?.[os.platform()]?.[os.arch()] || options.packageJson.scrypted.pythonVersion?.default;
|
90
|
+
const pluginPythonVersion: string = options.packageJson.scrypted.pythonVersion?.[os.platform()]?.[os.arch()] || options.packageJson.scrypted.pythonVersion?.default;
|
89
91
|
|
90
92
|
if (!pythonPath) {
|
91
93
|
if (os.platform() === 'win32') {
|
@@ -114,53 +116,64 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
|
|
114
116
|
this.worker.stderr.pipe(this.stderr);
|
115
117
|
};
|
116
118
|
|
117
|
-
|
118
119
|
// if the plugin requests a specific python, then install it via portable python
|
119
|
-
if (pluginPythonVersion) {
|
120
|
-
|
121
|
-
|
120
|
+
if (!pluginPythonVersion) {
|
121
|
+
setup();
|
122
|
+
this.peerin = this.worker.stdio[3] as Writable;
|
123
|
+
this.peerout = this.worker.stdio[4] as Readable;
|
124
|
+
this.setupWorker();
|
125
|
+
return;
|
126
|
+
}
|
122
127
|
|
123
|
-
|
124
|
-
|
128
|
+
const strippedPythonVersion = pluginPythonVersion.replace('.', '');
|
129
|
+
const envPython = process.env[`SCRYPTED_PYTHON${strippedPythonVersion}_PATH`];
|
130
|
+
if (fs.existsSync(envPython)) {
|
131
|
+
pythonPath = envPython;
|
132
|
+
setup();
|
133
|
+
this.peerin = this.worker.stdio[3] as Writable;
|
134
|
+
this.peerout = this.worker.stdio[4] as Readable;
|
135
|
+
this.setupWorker();
|
136
|
+
return;
|
137
|
+
}
|
125
138
|
|
126
|
-
|
127
|
-
|
128
|
-
};
|
139
|
+
const peerin = this.peerin = new PassThrough();
|
140
|
+
const peerout = this.peerout = new PassThrough();
|
129
141
|
|
130
|
-
|
131
|
-
|
132
|
-
const portableInstallPath = path.join(pyPath, pyVersion);
|
142
|
+
const finishSetup = () => {
|
143
|
+
setup();
|
133
144
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
}
|
147
|
-
catch (e) {
|
148
|
-
process.nextTick(() => {
|
149
|
-
this.emit('error', new Error('Failed to install portable python.'));
|
150
|
-
});
|
151
|
-
}
|
152
|
-
finally {
|
153
|
-
this.pythonInstallationComplete = true
|
154
|
-
}
|
155
|
-
})();
|
156
|
-
}
|
145
|
+
peerin.pipe(this.worker.stdio[3] as Writable);
|
146
|
+
(this.worker.stdio[4] as Readable).pipe(peerout);
|
147
|
+
};
|
148
|
+
|
149
|
+
const pyVersion = require('py/package.json').version;
|
150
|
+
const pyPath = path.join(getPluginVolume(pluginId), 'py');
|
151
|
+
const portableInstallPath = path.join(pyPath, pyVersion);
|
152
|
+
|
153
|
+
const py = new PortablePython(pluginPythonVersion, portableInstallPath);
|
154
|
+
if (fs.existsSync(py.executablePath)) {
|
155
|
+
pythonPath = py.executablePath;
|
156
|
+
finishSetup();
|
157
157
|
}
|
158
158
|
else {
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
159
|
+
(async () => {
|
160
|
+
try {
|
161
|
+
this.pythonInstallationComplete = false;
|
162
|
+
await fs.promises.rm(pyPath, { recursive: true, force: true }).catch(() => { });
|
163
|
+
pythonPath = await installScryptedServerRequirements(pluginPythonVersion, portableInstallPath);
|
164
|
+
finishSetup();
|
165
|
+
}
|
166
|
+
catch (e) {
|
167
|
+
process.nextTick(() => {
|
168
|
+
this.emit('error', new Error('Failed to install portable python.'));
|
169
|
+
});
|
170
|
+
}
|
171
|
+
finally {
|
172
|
+
this.pythonInstallationComplete = true
|
173
|
+
}
|
174
|
+
})();
|
163
175
|
}
|
176
|
+
|
164
177
|
}
|
165
178
|
|
166
179
|
setupRpcPeer(peer: RpcPeer): void {
|