wstp-node 0.4.5 → 0.4.6
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/package.json +1 -1
- package/scripts/diagnose-windows.ps1 +4 -2
- package/scripts/wstp_dir.js +72 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wstp-node",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Native Node.js addon for Wolfram/Mathematica WSTP — kernel sessions with evaluation queue, streaming Print/messages, Dialog subsessions, and side-channel WstpReader",
|
|
5
5
|
"main": "build/Release/wstp.node",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -13,8 +13,10 @@ $files = @("wstp.h", "wstp64i4s.lib")
|
|
|
13
13
|
$searchRoots = @(
|
|
14
14
|
"C:\Program Files\Wolfram Research",
|
|
15
15
|
"C:\Program Files (x86)\Wolfram Research",
|
|
16
|
-
"$env:LOCALAPPDATA\Programs\Wolfram Research"
|
|
17
|
-
|
|
16
|
+
"$env:LOCALAPPDATA\Programs\Wolfram Research",
|
|
17
|
+
"C:\Program Files\Wolfram Research\Mathematica",
|
|
18
|
+
"C:\Program Files\Wolfram Research\Wolfram Engine"
|
|
19
|
+
) | Where-Object { (Test-Path $_) -and -not (Test-Path (Join-Path $_ "wsl.exe")) }
|
|
18
20
|
|
|
19
21
|
$found = @{}
|
|
20
22
|
|
package/scripts/wstp_dir.js
CHANGED
|
@@ -22,67 +22,89 @@ function resolve () {
|
|
|
22
22
|
|
|
23
23
|
// ── 2. Windows ──────────────────────────────────────────────────────────
|
|
24
24
|
if (process.platform === 'win32') {
|
|
25
|
-
const
|
|
25
|
+
const pf = process.env.PROGRAMFILES || 'C:\\Program Files';
|
|
26
|
+
const pf86 = process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)';
|
|
27
|
+
const local = process.env.LOCALAPPDATA || '';
|
|
26
28
|
|
|
27
|
-
//
|
|
28
|
-
const
|
|
29
|
-
'Wolfram Research
|
|
30
|
-
'Wolfram Research
|
|
31
|
-
'Wolfram Research
|
|
32
|
-
];
|
|
29
|
+
// All candidate root directories to search under
|
|
30
|
+
const searchRoots = [
|
|
31
|
+
path.join(pf, 'Wolfram Research'),
|
|
32
|
+
path.join(pf86, 'Wolfram Research'),
|
|
33
|
+
local ? path.join(local, 'Programs', 'Wolfram Research') : null,
|
|
34
|
+
].filter(Boolean);
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
36
|
+
// Product subfolder names to try
|
|
37
|
+
const productNames = ['Mathematica', 'Wolfram Engine', 'WolframEngine'];
|
|
38
|
+
|
|
39
|
+
for (const root of searchRoots) {
|
|
40
|
+
let rootEntries;
|
|
41
|
+
try { rootEntries = fs.readdirSync(root); } catch (e) { continue; }
|
|
42
|
+
|
|
43
|
+
for (const product of productNames) {
|
|
44
|
+
const productDir = path.join(root, product);
|
|
45
|
+
let entries;
|
|
46
|
+
try { entries = fs.readdirSync(productDir); } catch (e) { continue; }
|
|
47
|
+
|
|
48
|
+
// Skip if this looks like WSL rather than a Wolfram product
|
|
49
|
+
if (entries.includes('wsl.exe') || entries.includes('wslservice.exe')) {
|
|
50
|
+
process.stderr.write(
|
|
51
|
+
`wstp_dir: skipping "${productDir}" — looks like WSL, not Wolfram\n`
|
|
52
|
+
);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
// Find version subfolders (e.g. "14.2", "13.1") — dirs starting with a digit
|
|
57
|
+
const versions = entries
|
|
58
|
+
.filter(d => {
|
|
59
|
+
if (!/^\d/.test(d)) return false;
|
|
60
|
+
try { return fs.statSync(path.join(productDir, d)).isDirectory(); } catch (e) { return false; }
|
|
61
|
+
})
|
|
62
|
+
.sort()
|
|
63
|
+
.reverse();
|
|
64
|
+
|
|
65
|
+
if (!versions.length) {
|
|
66
|
+
process.stderr.write(
|
|
67
|
+
`wstp_dir: "${productDir}" has no version subfolder — skipping\n` +
|
|
68
|
+
` Contents: ${entries.join(', ')}\n`
|
|
69
|
+
);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const wstp = path.join(
|
|
74
|
+
productDir, versions[0],
|
|
75
|
+
'SystemFiles', 'Links', 'WSTP', 'DeveloperKit',
|
|
76
|
+
'Windows-x86-64', 'CompilerAdditions'
|
|
70
77
|
);
|
|
71
|
-
|
|
78
|
+
|
|
79
|
+
const hasHeader = fs.existsSync(path.join(wstp, 'wstp.h'));
|
|
80
|
+
const hasLib = fs.existsSync(path.join(wstp, 'wstp64i4s.lib'));
|
|
81
|
+
|
|
82
|
+
if (!hasHeader || !hasLib) {
|
|
83
|
+
process.stderr.write(
|
|
84
|
+
`wstp_dir: found version "${versions[0]}" but WSTP DeveloperKit missing.\n` +
|
|
85
|
+
` Expected both files inside:\n` +
|
|
86
|
+
` ${wstp}\n` +
|
|
87
|
+
` wstp.h (C header) — ${hasHeader ? 'FOUND' : 'MISSING'}\n` +
|
|
88
|
+
` wstp64i4s.lib (import lib) — ${hasLib ? 'FOUND' : 'MISSING'}\n`
|
|
89
|
+
);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return wstp;
|
|
72
94
|
}
|
|
73
|
-
return wstp;
|
|
74
95
|
}
|
|
75
96
|
|
|
76
97
|
throw new Error(
|
|
77
|
-
`WSTP DeveloperKit not found.\n` +
|
|
78
|
-
`
|
|
79
|
-
`The build needs these two files:\n` +
|
|
98
|
+
`WSTP DeveloperKit not found on Windows.\n\n` +
|
|
99
|
+
`The build requires two files from the Wolfram Engine / Mathematica installation:\n` +
|
|
80
100
|
` wstp.h (C header)\n` +
|
|
81
101
|
` wstp64i4s.lib (static import library)\n\n` +
|
|
82
|
-
`
|
|
102
|
+
`These live inside:\n` +
|
|
103
|
+
` <WolframEngine>\\<version>\\SystemFiles\\Links\\WSTP\\DeveloperKit\\Windows-x86-64\\CompilerAdditions\\\n\n` +
|
|
104
|
+
`Run the diagnostic to find them:\n` +
|
|
83
105
|
` powershell -ExecutionPolicy Bypass -File scripts\\diagnose-windows.ps1\n\n` +
|
|
84
|
-
`Then set WSTP_DIR
|
|
85
|
-
` set WSTP_DIR
|
|
106
|
+
`Then set WSTP_DIR and retry:\n` +
|
|
107
|
+
` set WSTP_DIR=<path shown above>\n` +
|
|
86
108
|
` npm install`
|
|
87
109
|
);
|
|
88
110
|
}
|