blitzwing 0.1.3 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/install.js +48 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blitzwing",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Interactive setup wizard to join a Blitzwing Petals mother swarm as a compute contributor",
5
5
  "bin": {
6
6
  "blitzwing": "bin/blitzwing.js"
package/src/install.js CHANGED
@@ -18,41 +18,59 @@ function venvPip() {
18
18
  return path.join(VENV_PATH, "bin", "pip");
19
19
  }
20
20
 
21
+ function pythonVersion(bin) {
22
+ try {
23
+ const ver = execFileSync(bin, ["--version"], { encoding: "utf8" }).trim();
24
+ const m = ver.match(/Python (\d+)\.(\d+)/);
25
+ if (!m) return null;
26
+ return { ver, major: Number(m[1]), minor: Number(m[2]) };
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+
32
+ function isPetalsCompatible(info) {
33
+ return info && info.major === 3 && info.minor >= 10 && info.minor <= 11;
34
+ }
35
+
21
36
  export function ensurePython() {
22
- // Prefer 3.10/3.11 — Petals/hivemind break on 3.12+ / 3.13+
23
- const candidates = ["python3.11", "python3.10", "python3", "python"];
24
- let py = null;
25
- let ver = "";
37
+ // Petals/hivemind break on 3.12+. Never fall back to a too-new interpreter.
38
+ const candidates = [];
39
+ const envBin = process.env.BLITZWING_PYTHON || process.env.PETALS_PYTHON;
40
+ if (envBin) candidates.push(envBin);
41
+ if (process.env.CONDA_PREFIX) {
42
+ candidates.push(
43
+ path.join(process.env.CONDA_PREFIX, "bin", "python3.11"),
44
+ path.join(process.env.CONDA_PREFIX, "bin", "python3.10"),
45
+ path.join(process.env.CONDA_PREFIX, "bin", "python")
46
+ );
47
+ }
48
+ candidates.push(
49
+ path.join(process.env.HOME || "", "miniconda", "envs", "blitzwing", "bin", "python3.11"),
50
+ path.join(process.env.HOME || "", "miniconda", "envs", "blitzwing", "bin", "python"),
51
+ path.join(process.env.HOME || "", "miniconda3", "envs", "blitzwing", "bin", "python3.11"),
52
+ path.join(process.env.HOME || "", "miniconda3", "envs", "blitzwing", "bin", "python"),
53
+ "python3.11",
54
+ "python3.10"
55
+ );
56
+
57
+ const seen = new Set();
26
58
  for (const cmd of candidates) {
27
- const found = which(cmd);
59
+ if (!cmd || seen.has(cmd)) continue;
60
+ seen.add(cmd);
61
+ const found = cmd.includes("/") || cmd.includes("\\") ? (fs.existsSync(cmd) ? cmd : null) : which(cmd);
28
62
  if (!found) continue;
29
- try {
30
- ver = execFileSync(found, ["--version"], { encoding: "utf8" }).trim();
31
- const m = ver.match(/Python (\d+)\.(\d+)/);
32
- if (!m) continue;
33
- const major = Number(m[1]);
34
- const minor = Number(m[2]);
35
- if (major === 3 && minor >= 10 && minor <= 11) {
36
- py = found;
37
- break;
38
- }
39
- if (!py) {
40
- py = found; // fallback, may fail later
41
- }
42
- } catch {
43
- /* try next */
63
+ const info = pythonVersion(found);
64
+ if (isPetalsCompatible(info)) {
65
+ return { py: found, ver: info.ver };
44
66
  }
45
67
  }
46
- if (!py) {
47
- throw new Error("Python 3.10 or 3.11 is required. Install via conda/miniconda and re-run.");
48
- }
49
- const m = ver.match(/Python (\d+)\.(\d+)/);
50
- if (m && (Number(m[1]) !== 3 || Number(m[2]) > 11)) {
51
- throw new Error(
52
- `${ver} is too new for Petals. Use Python 3.11 (e.g. conda create -n blitzwing python=3.11).`
53
- );
54
- }
55
- return { py, ver };
68
+
69
+ throw new Error(
70
+ "Python 3.10 or 3.11 is required (3.12+ will not work). " +
71
+ "Install with: conda create -n blitzwing python=3.11 && conda activate blitzwing " +
72
+ "or set BLITZWING_PYTHON=/path/to/python3.11"
73
+ );
56
74
  }
57
75
 
58
76
  function petalsImportable(python) {