@emend-ai/utim 1.43.1 → 1.43.3
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/utim.js +15 -8
- package/package.json +1 -1
- package/scripts/postinstall.js +18 -8
package/bin/utim.js
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
const { spawnSync, spawn } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
5
6
|
const fs = require('fs');
|
|
6
7
|
|
|
7
8
|
const args = process.argv.slice(2);
|
|
9
|
+
const useShell = os.platform() === 'win32';
|
|
8
10
|
|
|
9
11
|
// ── Find a working Python 3 interpreter ──────────────────────────────────────
|
|
10
12
|
function findPython() {
|
|
11
13
|
for (const candidate of ['python3', 'python']) {
|
|
12
14
|
try {
|
|
13
|
-
const r = spawnSync(candidate, ['--version'], { encoding: 'utf8', timeout: 3000, shell:
|
|
15
|
+
const r = spawnSync(candidate, ['--version'], { encoding: 'utf8', timeout: 3000, shell: useShell });
|
|
14
16
|
const out = (r.stdout || '') + (r.stderr || '');
|
|
15
17
|
if (out.includes('Python 3')) return candidate;
|
|
16
18
|
} catch (_) {}
|
|
@@ -21,11 +23,11 @@ function findPython() {
|
|
|
21
23
|
// ── Attempt to launch a command, return true if successful ───────────────────
|
|
22
24
|
function tryLaunch(cmd, launchArgs) {
|
|
23
25
|
try {
|
|
24
|
-
const probe = spawnSync(cmd, ['--version'], { shell:
|
|
26
|
+
const probe = spawnSync(cmd, ['--version'], { shell: useShell, timeout: 3000, encoding: 'utf8' });
|
|
25
27
|
const out = (probe.stdout || '') + (probe.stderr || '');
|
|
26
28
|
// accept if exit 0 OR if it printed something (some tools exit non-0 for --version)
|
|
27
29
|
if (probe.status === 0 || out.length > 0) {
|
|
28
|
-
const proc = spawn(cmd, launchArgs, { stdio: 'inherit', shell:
|
|
30
|
+
const proc = spawn(cmd, launchArgs, { stdio: 'inherit', shell: useShell });
|
|
29
31
|
proc.on('exit', (code) => process.exit(code == null ? 0 : code));
|
|
30
32
|
return true;
|
|
31
33
|
}
|
|
@@ -41,9 +43,9 @@ function tryEntryPoint() {
|
|
|
41
43
|
// ── Try via `python -m utim_cli.utim` ───────────────────────────────────────
|
|
42
44
|
function tryModule(python) {
|
|
43
45
|
try {
|
|
44
|
-
const probe = spawnSync(python, ['-m', 'utim_cli', '--help'], { shell:
|
|
46
|
+
const probe = spawnSync(python, ['-m', 'utim_cli', '--help'], { shell: useShell, timeout: 5000 });
|
|
45
47
|
if (probe.status === 0) {
|
|
46
|
-
const proc = spawn(python, ['-m', 'utim_cli.utim', ...args], { stdio: 'inherit', shell:
|
|
48
|
+
const proc = spawn(python, ['-m', 'utim_cli.utim', ...args], { stdio: 'inherit', shell: useShell });
|
|
47
49
|
proc.on('exit', (code) => process.exit(code == null ? 0 : code));
|
|
48
50
|
return true;
|
|
49
51
|
}
|
|
@@ -56,7 +58,7 @@ function selfInstallAndRun(python) {
|
|
|
56
58
|
console.error('\n⚙ First run: installing UTIM Python engine from PyPI...');
|
|
57
59
|
const install = spawnSync(python, ['-m', 'pip', 'install', '--upgrade', 'utim-cli'], {
|
|
58
60
|
stdio: 'inherit',
|
|
59
|
-
shell:
|
|
61
|
+
shell: useShell,
|
|
60
62
|
});
|
|
61
63
|
if (install.status === 0) {
|
|
62
64
|
// Retry the entry point after install
|
|
@@ -75,11 +77,16 @@ const ok =
|
|
|
75
77
|
|
|
76
78
|
if (!ok) {
|
|
77
79
|
console.error('\nError: UTIM Engine could not start.');
|
|
78
|
-
|
|
80
|
+
const isTermux = (process.env.PREFIX && process.env.PREFIX.includes('com.termux')) || fs.existsSync('/data/data/com.termux');
|
|
81
|
+
if (isTermux) {
|
|
82
|
+
console.error('\n💡 Note for Termux Users: Precompiled binaries are required to avoid Rust compiler errors (pydantic-core).');
|
|
83
|
+
console.error(' Please run: pkg install python-cryptography python-pydantic');
|
|
84
|
+
console.error(' And then: pip install utim-cli');
|
|
85
|
+
} else if (!python) {
|
|
79
86
|
console.error('Python 3 was not found. On Termux run: pkg install python');
|
|
80
87
|
} else {
|
|
81
88
|
console.error(`Tried Python at: ${python}`);
|
|
82
|
-
console.error('Run manually: pip install
|
|
89
|
+
console.error('Run manually: pip install utim-cli or pip3 install --upgrade utim-cli');
|
|
83
90
|
}
|
|
84
91
|
process.exit(1);
|
|
85
92
|
}
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -14,6 +14,7 @@ const path = require('path');
|
|
|
14
14
|
const os = require('os');
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
|
|
17
|
+
const useShell = os.platform() === 'win32';
|
|
17
18
|
const pkgDir = path.resolve(__dirname, '..');
|
|
18
19
|
|
|
19
20
|
// ── Find a usable Python 3 interpreter ────────────────────────────────────────
|
|
@@ -23,7 +24,7 @@ function findPython() {
|
|
|
23
24
|
const r = spawnSync(candidate, ['--version'], {
|
|
24
25
|
encoding: 'utf8',
|
|
25
26
|
timeout: 4000,
|
|
26
|
-
shell:
|
|
27
|
+
shell: useShell,
|
|
27
28
|
});
|
|
28
29
|
const out = (r.stdout || '') + (r.stderr || '');
|
|
29
30
|
if (out.includes('Python 3')) return candidate;
|
|
@@ -39,7 +40,7 @@ function installFromPyPI(python) {
|
|
|
39
40
|
const r = spawnSync(
|
|
40
41
|
python,
|
|
41
42
|
['-m', 'pip', 'install', '--upgrade', 'utim-cli'],
|
|
42
|
-
{ stdio: 'inherit', shell:
|
|
43
|
+
{ stdio: 'inherit', shell: useShell }
|
|
43
44
|
);
|
|
44
45
|
return r.status === 0;
|
|
45
46
|
} catch (_) {
|
|
@@ -79,12 +80,21 @@ setExecuteBit();
|
|
|
79
80
|
if (ok) {
|
|
80
81
|
console.log('\n✅ UTIM installed successfully. Run utim to get started.\n');
|
|
81
82
|
} else {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
const isTermux = (process.env.PREFIX && process.env.PREFIX.includes('com.termux')) || fs.existsSync('/data/data/com.termux');
|
|
84
|
+
if (isTermux) {
|
|
85
|
+
console.warn(
|
|
86
|
+
'\n💡 Note for Termux Users: Precompiled binaries are required to avoid Rust compiler errors (pydantic-core).\n' +
|
|
87
|
+
' Please run: pkg install python-cryptography python-pydantic\n' +
|
|
88
|
+
' And then: pip install utim-cli\n'
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
console.warn(
|
|
92
|
+
'\n⚠ pip install failed. Try running manually:\n' +
|
|
93
|
+
' pip install utim-cli\n' +
|
|
94
|
+
' or:\n' +
|
|
95
|
+
' pip3 install utim-cli\n'
|
|
96
|
+
);
|
|
97
|
+
}
|
|
88
98
|
// Exit 0 — don't break the npm install; user can manually pip install
|
|
89
99
|
process.exit(0);
|
|
90
100
|
}
|