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.
- package/package.json +1 -1
- package/src/install.js +48 -30
package/package.json
CHANGED
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
|
-
//
|
|
23
|
-
const candidates = [
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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) {
|