machinaos 0.0.73 → 0.0.74
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/client/package.json +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +36 -23
package/client/package.json
CHANGED
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Runs install.js to check deps, install npm/Python packages, build.
|
|
6
6
|
* WhatsApp RPC is now an npm dependency - binary downloaded by its own postinstall.
|
|
7
7
|
*/
|
|
8
|
-
import { spawn } from 'child_process';
|
|
8
|
+
import { spawn, execSync } from 'child_process';
|
|
9
9
|
import { resolve, dirname } from 'path';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
11
11
|
import { existsSync, chmodSync } from 'fs';
|
|
@@ -73,18 +73,6 @@ function runScript(scriptPath) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
function runPython(args) {
|
|
77
|
-
return new Promise((resolveP, reject) => {
|
|
78
|
-
const cmd = process.platform === 'win32' ? 'python' : 'python3';
|
|
79
|
-
const child = spawn(cmd, args, { cwd: ROOT, stdio: 'inherit' });
|
|
80
|
-
child.on('error', reject);
|
|
81
|
-
child.on('close', (code) => {
|
|
82
|
-
if (code === 0) resolveP();
|
|
83
|
-
else reject(new Error(`${cmd} exited with code ${code}`));
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
76
|
async function main() {
|
|
89
77
|
try {
|
|
90
78
|
// Fix executable permissions on Unix
|
|
@@ -94,17 +82,42 @@ async function main() {
|
|
|
94
82
|
console.log('Installing dependencies...');
|
|
95
83
|
await runScript(resolve(__dirname, 'install.js'));
|
|
96
84
|
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
|
|
85
|
+
// Note: we deliberately do NOT `pip install -e ./machina` here. An
|
|
86
|
+
// editable install creates a `Scripts/machina.exe` (or
|
|
87
|
+
// `bin/machina`) entry-point that imports `machina.cli` from the
|
|
88
|
+
// package's npm install directory. When npm later moves, prunes,
|
|
89
|
+
// or upgrades that directory, the shim survives but its target
|
|
90
|
+
// disappears -- the user runs `machina start` and gets
|
|
91
|
+
// `ModuleNotFoundError: No module named 'machina'`. The same
|
|
92
|
+
// shim also wins PATH precedence over the npm bin shim at
|
|
93
|
+
// bin/cli.js, masking the real entry point.
|
|
94
|
+
//
|
|
95
|
+
// Both call sites that need the Python CLI use `python -m machina
|
|
96
|
+
// <cmd>` (npm run start, .github/workflows/release.yml version
|
|
97
|
+
// sync). `-m` resolves the package from the working directory's
|
|
98
|
+
// sys.path entry, which `bin/cli.js` already pins to the npm
|
|
99
|
+
// package root via `cwd: ROOT`. No pip install required.
|
|
100
|
+
|
|
101
|
+
// Detect a stale `Scripts/machina.exe` (or `bin/machina`) left
|
|
102
|
+
// behind by a prior version's `pip install -e ./machina`. If pip
|
|
103
|
+
// shows the package installed but the current `machina` on PATH
|
|
104
|
+
// is NOT our Node shim, surface the cleanup command -- otherwise
|
|
105
|
+
// the user keeps hitting the dead Python entry-point even after
|
|
106
|
+
// upgrading.
|
|
102
107
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const pipShow = execSync('python -m pip show machina 2>nul || python3 -m pip show machina 2>/dev/null', {
|
|
109
|
+
encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'], shell: true,
|
|
110
|
+
}).trim();
|
|
111
|
+
if (pipShow) {
|
|
112
|
+
console.log('');
|
|
113
|
+
console.log('Notice: a previous install left `machina` registered with pip.');
|
|
114
|
+
console.log('If `machina start` fails with "No module named \'machina\'",');
|
|
115
|
+
console.log('clean it up once with:');
|
|
116
|
+
console.log(' python -m pip uninstall -y machina');
|
|
117
|
+
console.log('');
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
// pip not present, or the package isn't installed -- nothing to warn about.
|
|
108
121
|
}
|
|
109
122
|
|
|
110
123
|
console.log('');
|