recursive-llm-ts 2.0.7 → 2.0.10
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/dist/bunpy-bridge.js +5 -3
- package/dist/rlm-bridge.js +5 -3
- package/package.json +1 -1
- package/scripts/install-python-deps.js +45 -17
package/dist/bunpy-bridge.js
CHANGED
|
@@ -77,8 +77,11 @@ class BunpyBridge {
|
|
|
77
77
|
}
|
|
78
78
|
// Import sys module to add path
|
|
79
79
|
const sys = this.python.import('sys');
|
|
80
|
+
const pythonExecutable = String(sys.executable || 'python');
|
|
81
|
+
const pythonCmd = pythonExecutable.includes(' ') ? `"${pythonExecutable}"` : pythonExecutable;
|
|
80
82
|
const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
|
|
81
83
|
const pythonSrcPath = path.join(pythonPackagePath, 'src');
|
|
84
|
+
const pipCmd = `${pythonCmd} -m pip install -e "${pythonPackagePath}"`;
|
|
82
85
|
sys.path.insert(0, pythonSrcPath);
|
|
83
86
|
// Try to import rlm, install deps if import fails
|
|
84
87
|
try {
|
|
@@ -90,7 +93,6 @@ class BunpyBridge {
|
|
|
90
93
|
console.log('[recursive-llm-ts] Installing Python dependencies (first time only)...');
|
|
91
94
|
try {
|
|
92
95
|
const { execSync } = yield Promise.resolve().then(() => __importStar(require('child_process')));
|
|
93
|
-
const pipCmd = `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
94
96
|
execSync(pipCmd, { stdio: 'inherit' });
|
|
95
97
|
console.log('[recursive-llm-ts] ✓ Python dependencies installed');
|
|
96
98
|
// Try import again
|
|
@@ -98,13 +100,13 @@ class BunpyBridge {
|
|
|
98
100
|
}
|
|
99
101
|
catch (installError) {
|
|
100
102
|
throw new Error('Failed to import rlm module after installing dependencies.\n' +
|
|
101
|
-
`Manual installation:
|
|
103
|
+
`Manual installation: ${pipCmd}\n` +
|
|
102
104
|
`Error: ${installError.message || installError}`);
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
else {
|
|
106
108
|
throw new Error('Failed to import rlm module.\n' +
|
|
107
|
-
`Run:
|
|
109
|
+
`Run: ${pipCmd}\n` +
|
|
108
110
|
`Original error: ${error.message || error}`);
|
|
109
111
|
}
|
|
110
112
|
}
|
package/dist/rlm-bridge.js
CHANGED
|
@@ -79,6 +79,9 @@ class PythoniaBridge {
|
|
|
79
79
|
const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
|
|
80
80
|
// Import sys module to add path
|
|
81
81
|
const sys = yield this.python('sys');
|
|
82
|
+
const pythonExecutable = String((yield sys.executable) || 'python');
|
|
83
|
+
const pythonCmd = pythonExecutable.includes(' ') ? `"${pythonExecutable}"` : pythonExecutable;
|
|
84
|
+
const pipCmd = `${pythonCmd} -m pip install -e "${pythonPackagePath}"`;
|
|
82
85
|
const pathList = yield sys.path;
|
|
83
86
|
yield pathList.insert(0, path.join(pythonPackagePath, 'src'));
|
|
84
87
|
// Try to import rlm, install deps if import fails
|
|
@@ -91,7 +94,6 @@ class PythoniaBridge {
|
|
|
91
94
|
console.log('[recursive-llm-ts] Installing Python dependencies (first time only)...');
|
|
92
95
|
try {
|
|
93
96
|
const { execSync } = yield Promise.resolve().then(() => __importStar(require('child_process')));
|
|
94
|
-
const pipCmd = `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
95
97
|
execSync(pipCmd, { stdio: 'inherit' });
|
|
96
98
|
console.log('[recursive-llm-ts] ✓ Python dependencies installed');
|
|
97
99
|
// Try import again
|
|
@@ -99,13 +101,13 @@ class PythoniaBridge {
|
|
|
99
101
|
}
|
|
100
102
|
catch (installError) {
|
|
101
103
|
throw new Error('Failed to import rlm module after installing dependencies.\n' +
|
|
102
|
-
`Manual installation:
|
|
104
|
+
`Manual installation: ${pipCmd}\n` +
|
|
103
105
|
`Error: ${installError.message || installError}`);
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
else {
|
|
107
109
|
throw new Error('Failed to import rlm module.\n' +
|
|
108
|
-
`Run:
|
|
110
|
+
`Run: ${pipCmd}\n` +
|
|
109
111
|
`Original error: ${error.message || error}`);
|
|
110
112
|
}
|
|
111
113
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { execSync } = require('child_process');
|
|
2
|
+
const { execSync, execFileSync } = require('child_process');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
@@ -16,28 +16,56 @@ if (!fs.existsSync(pyprojectPath)) {
|
|
|
16
16
|
console.log('[recursive-llm-ts] Installing Python dependencies...');
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const pythonCandidates = [];
|
|
20
|
+
if (process.env.PYTHON) {
|
|
21
|
+
pythonCandidates.push({ command: process.env.PYTHON, args: [] });
|
|
22
|
+
}
|
|
23
|
+
if (process.platform === 'win32') {
|
|
24
|
+
pythonCandidates.push({ command: 'py', args: ['-3'] });
|
|
25
|
+
pythonCandidates.push({ command: 'python', args: [] });
|
|
26
|
+
pythonCandidates.push({ command: 'python3', args: [] });
|
|
27
|
+
} else {
|
|
28
|
+
pythonCandidates.push({ command: 'python3', args: [] });
|
|
29
|
+
pythonCandidates.push({ command: 'python', args: [] });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let pythonCmd = null;
|
|
33
|
+
for (const candidate of pythonCandidates) {
|
|
34
|
+
try {
|
|
35
|
+
execFileSync(candidate.command, [...candidate.args, '--version'], { stdio: 'pipe' });
|
|
36
|
+
pythonCmd = candidate;
|
|
37
|
+
break;
|
|
38
|
+
} catch {
|
|
39
|
+
// Try next candidate
|
|
40
|
+
}
|
|
25
41
|
}
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
if (pythonCmd) {
|
|
44
|
+
execFileSync(
|
|
45
|
+
pythonCmd.command,
|
|
46
|
+
[...pythonCmd.args, '-m', 'pip', 'install', '-e', pythonPackagePath],
|
|
47
|
+
{ stdio: 'inherit', cwd: pythonPackagePath }
|
|
48
|
+
);
|
|
49
|
+
} else {
|
|
50
|
+
// Fall back to pip/pip3 if a Python executable wasn't found
|
|
51
|
+
try {
|
|
52
|
+
execSync('pip --version', { stdio: 'pipe' });
|
|
53
|
+
} catch {
|
|
54
|
+
execSync('pip3 --version', { stdio: 'pipe' });
|
|
55
|
+
}
|
|
56
|
+
const pipCommand = process.platform === 'win32'
|
|
57
|
+
? `pip install -e "${pythonPackagePath}"`
|
|
58
|
+
: `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
59
|
+
execSync(pipCommand, {
|
|
60
|
+
stdio: 'inherit',
|
|
61
|
+
cwd: pythonPackagePath
|
|
62
|
+
});
|
|
63
|
+
}
|
|
36
64
|
console.log('[recursive-llm-ts] ✓ Python dependencies installed successfully');
|
|
37
65
|
} catch (error) {
|
|
38
66
|
console.warn('[recursive-llm-ts] Warning: Failed to auto-install Python dependencies');
|
|
39
67
|
console.warn('[recursive-llm-ts] This is not critical - you can install them manually:');
|
|
40
|
-
console.warn(`[recursive-llm-ts] cd node_modules/recursive-llm-ts/recursive-llm && pip install -e .`);
|
|
68
|
+
console.warn(`[recursive-llm-ts] cd node_modules/recursive-llm-ts/recursive-llm && python -m pip install -e .`);
|
|
41
69
|
console.warn('[recursive-llm-ts] Or ensure Python 3.9+ and pip are in your PATH');
|
|
42
70
|
// Don't fail the npm install - exit with 0
|
|
43
71
|
process.exit(0);
|