wstp-node 0.4.2 → 0.4.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wstp-node",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
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",
@@ -16,9 +16,16 @@ const opts = { cwd: root, stdio: 'inherit' };
16
16
 
17
17
  if (process.platform === 'win32') {
18
18
  // On Windows: use node-gyp via the local devDependency.
19
- // npx picks up the node-gyp installed in node_modules/.bin.
19
+ // --msvs_version 2022 avoids gyp failing to auto-detect VS via PowerShell
20
+ // (common when execution policy is Restricted or VS was just installed).
21
+ // Falls back gracefully if an older VS is the only one present.
20
22
  const mode = process.argv[2] === 'debug' ? '--debug' : '--release';
21
- execSync(`npx node-gyp rebuild ${mode}`, opts);
23
+ try {
24
+ execSync(`npx node-gyp rebuild ${mode} --msvs_version 2022`, opts);
25
+ } catch (_e) {
26
+ // Retry without version pin in case they have VS 2019 etc.
27
+ execSync(`npx node-gyp rebuild ${mode}`, opts);
28
+ }
22
29
  } else {
23
30
  // macOS / Linux: use the hand-crafted bash script (faster, no gyp overhead).
24
31
  const arg = process.argv[2] || ''; // '' | 'debug' | 'clean'
@@ -22,24 +22,59 @@ function resolve () {
22
22
 
23
23
  // ── 2. Windows ──────────────────────────────────────────────────────────
24
24
  if (process.platform === 'win32') {
25
- const base = 'C:\\Program Files\\Wolfram Research\\Wolfram Engine';
26
- let versions;
27
- try {
28
- versions = fs.readdirSync(base)
29
- .filter(d => /^\d/.test(d))
25
+ const base = process.env.PROGRAMFILES || 'C:\\Program Files';
26
+
27
+ // Wolfram products to try, in priority order
28
+ const products = [
29
+ 'Wolfram Research\\Wolfram Engine',
30
+ 'Wolfram Research\\Mathematica',
31
+ 'Wolfram Research\\WolframEngine',
32
+ ];
33
+
34
+ for (const product of products) {
35
+ const productDir = path.join(base, product);
36
+ let entries;
37
+ try { entries = fs.readdirSync(productDir); } catch (e) { continue; }
38
+
39
+ // Find version subfolders (e.g. "14.2", "13.1") — any dir starting with a digit
40
+ const versions = entries
41
+ .filter(d => {
42
+ if (!/^\d/.test(d)) return false;
43
+ try { return fs.statSync(path.join(productDir, d)).isDirectory(); } catch (e) { return false; }
44
+ })
30
45
  .sort()
31
46
  .reverse();
32
- } catch (e) {
33
- throw new Error(
34
- `WSTP DeveloperKit not found at "${base}".\n` +
35
- `Install Wolfram Engine or set WSTP_DIR to the CompilerAdditions folder.`
47
+
48
+ if (!versions.length) {
49
+ // Help diagnose: show what IS there
50
+ process.stderr.write(
51
+ `wstp_dir: found "${productDir}" but no version subfolder.\n` +
52
+ ` Contents: ${entries.join(', ') || '(empty)'}\n`
53
+ );
54
+ continue;
55
+ }
56
+
57
+ const wstp = path.join(
58
+ productDir, versions[0],
59
+ 'SystemFiles', 'Links', 'WSTP', 'DeveloperKit',
60
+ 'Windows-x86-64', 'CompilerAdditions'
36
61
  );
62
+ if (!fs.existsSync(path.join(wstp, 'wstp.h')) &&
63
+ !fs.existsSync(path.join(wstp, 'wstp64i4s.lib'))) {
64
+ process.stderr.write(
65
+ `wstp_dir: WSTP DeveloperKit not found at expected path:\n ${wstp}\n`
66
+ );
67
+ continue;
68
+ }
69
+ return wstp;
37
70
  }
38
- if (!versions.length) throw new Error(`No Wolfram Engine version found under "${base}"`);
39
- return path.join(
40
- base, versions[0],
41
- 'SystemFiles', 'Links', 'WSTP', 'DeveloperKit',
42
- 'Windows-x86-64', 'CompilerAdditions'
71
+
72
+ throw new Error(
73
+ `WSTP DeveloperKit not found.\n` +
74
+ `Tried under "${base}" for: ${products.join(', ')}\n\n` +
75
+ `Set WSTP_DIR to your CompilerAdditions folder, e.g.:\n` +
76
+ ` set WSTP_DIR=C:\\Program Files\\Wolfram Research\\Wolfram Engine\\14.2\\SystemFiles\\Links\\WSTP\\DeveloperKit\\Windows-x86-64\\CompilerAdditions\n` +
77
+ `then run npm install again.`
43
78
  );
44
79
  }
45
80