blitzwing 0.1.4 → 0.1.5

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 +38 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blitzwing",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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
@@ -33,11 +33,25 @@ function isPetalsCompatible(info) {
33
33
  return info && info.major === 3 && info.minor >= 10 && info.minor <= 11;
34
34
  }
35
35
 
36
+ function pinnedPythonPath() {
37
+ try {
38
+ const p = path.join(HOME_DIR, "python");
39
+ if (!fs.existsSync(p)) return null;
40
+ const bin = fs.readFileSync(p, "utf8").trim();
41
+ return bin || null;
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
36
47
  export function ensurePython() {
37
48
  // Petals/hivemind break on 3.12+. Never fall back to a too-new interpreter.
49
+ const home = process.env.HOME || process.env.USERPROFILE || "";
38
50
  const candidates = [];
39
51
  const envBin = process.env.BLITZWING_PYTHON || process.env.PETALS_PYTHON;
40
52
  if (envBin) candidates.push(envBin);
53
+ const pinned = pinnedPythonPath();
54
+ if (pinned) candidates.push(pinned);
41
55
  if (process.env.CONDA_PREFIX) {
42
56
  candidates.push(
43
57
  path.join(process.env.CONDA_PREFIX, "bin", "python3.11"),
@@ -45,31 +59,43 @@ export function ensurePython() {
45
59
  path.join(process.env.CONDA_PREFIX, "bin", "python")
46
60
  );
47
61
  }
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
- );
62
+ for (const root of ["miniforge3", "mambaforge", "miniconda", "miniconda3", "anaconda3"]) {
63
+ candidates.push(
64
+ path.join(home, root, "envs", "blitzwing", "bin", "python3.11"),
65
+ path.join(home, root, "envs", "blitzwing", "bin", "python")
66
+ );
67
+ }
68
+ candidates.push("python3.11", "python3.10");
56
69
 
70
+ const tried = [];
57
71
  const seen = new Set();
58
72
  for (const cmd of candidates) {
59
73
  if (!cmd || seen.has(cmd)) continue;
60
74
  seen.add(cmd);
61
75
  const found = cmd.includes("/") || cmd.includes("\\") ? (fs.existsSync(cmd) ? cmd : null) : which(cmd);
62
- if (!found) continue;
76
+ if (!found) {
77
+ tried.push(`${cmd} (missing)`);
78
+ continue;
79
+ }
63
80
  const info = pythonVersion(found);
64
81
  if (isPetalsCompatible(info)) {
82
+ fs.mkdirSync(HOME_DIR, { recursive: true });
83
+ fs.writeFileSync(path.join(HOME_DIR, "python"), found + "\n");
65
84
  return { py: found, ver: info.ver };
66
85
  }
86
+ tried.push(`${found} (${info ? info.ver : "unreadable"})`);
67
87
  }
68
88
 
69
89
  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"
90
+ "Python 3.10 or 3.11 is required (3.12+ will not work).\n" +
91
+ "Checked:\n - " +
92
+ tried.slice(0, 12).join("\n - ") +
93
+ "\nFix:\n" +
94
+ " curl -LsSf https://astral.sh/uv/install.sh | sh && source $HOME/.local/bin/env\n" +
95
+ " uv python install 3.11\n" +
96
+ " export BLITZWING_PYTHON=\"$(uv python find 3.11)\"\n" +
97
+ " mkdir -p ~/.blitzwing && echo \"$BLITZWING_PYTHON\" > ~/.blitzwing/python\n" +
98
+ " blitzwing"
73
99
  );
74
100
  }
75
101