@xyrlan/mnemo 0.16.0 → 0.17.2
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/lib/bootstrap.js +1 -1
- package/lib/runInstall.js +45 -13
- package/package.json +1 -1
package/lib/bootstrap.js
CHANGED
package/lib/runInstall.js
CHANGED
|
@@ -41,24 +41,56 @@ function parseFlags(argv, { warn = (msg) => process.stderr.write(`warning: ${msg
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
// Decide what we need before installing anything.
|
|
45
|
+
//
|
|
46
|
+
// Installer first, Python second -- the reverse order bailed out on a machine
|
|
47
|
+
// that had uv but no system Python, which is precisely the case uv solves: it
|
|
48
|
+
// provisions its own CPython. The tool that would have worked was never
|
|
49
|
+
// reached, and the user was told to go install Python.
|
|
50
|
+
function resolveToolchain({ pickInstallerFn = pickInstaller, detectPythonFn = detectPython } = {}) {
|
|
51
|
+
const installer = pickInstallerFn();
|
|
52
|
+
const python = detectPythonFn();
|
|
53
|
+
|
|
54
|
+
if (installer === "uv") return { installer, python };
|
|
55
|
+
|
|
56
|
+
if (!installer) {
|
|
57
|
+
return {
|
|
58
|
+
error: python
|
|
59
|
+
? `No Python installer (uv, pipx, or pip) found on PATH.\n → ${pep668InstallHint()}`
|
|
60
|
+
: "Neither a Python installer nor Python 3.8+ was found.\n" +
|
|
61
|
+
" → Install uv (https://docs.astral.sh/uv/) — it brings its own Python:\n" +
|
|
62
|
+
" curl -LsSf https://astral.sh/uv/install.sh | sh",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// pipx and pip both run on the system interpreter.
|
|
67
|
+
if (!python) {
|
|
68
|
+
return {
|
|
69
|
+
error:
|
|
70
|
+
`Python 3.8+ not found (required by ${installer}).\n` +
|
|
71
|
+
" → Install Python 3.8+ (https://www.python.org/downloads/), or install uv,\n" +
|
|
72
|
+
" which brings its own: curl -LsSf https://astral.sh/uv/install.sh | sh",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return { installer, python };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
44
80
|
async function runInstall(argv) {
|
|
45
81
|
const flags = parseFlags(argv);
|
|
46
82
|
|
|
47
|
-
const py =
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
m.
|
|
83
|
+
const { installer, python: py, error } = resolveToolchain();
|
|
84
|
+
if (error) {
|
|
85
|
+
const [first, ...rest] = error.split("\n");
|
|
86
|
+
m.err(first);
|
|
87
|
+
rest.forEach((line) => m.plain(line));
|
|
51
88
|
return 1;
|
|
52
89
|
}
|
|
53
|
-
if (!flags.quiet)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!installer) {
|
|
57
|
-
m.err("No Python installer (uv, pipx, or pip) found on PATH.");
|
|
58
|
-
m.plain(` → ${pep668InstallHint()}`);
|
|
59
|
-
return 1;
|
|
90
|
+
if (!flags.quiet) {
|
|
91
|
+
if (py) m.ok(`Python ${py.version.major}.${py.version.minor} detected`);
|
|
92
|
+
m.ok(`installer: ${installer}`);
|
|
60
93
|
}
|
|
61
|
-
if (!flags.quiet) m.ok(`installer: ${installer}`);
|
|
62
94
|
|
|
63
95
|
const installed = isAlreadyInstalled();
|
|
64
96
|
if (installed && !flags.upgrade) {
|
|
@@ -100,4 +132,4 @@ async function runInstall(argv) {
|
|
|
100
132
|
}
|
|
101
133
|
|
|
102
134
|
|
|
103
|
-
module.exports = { runInstall, parseFlags };
|
|
135
|
+
module.exports = { runInstall, parseFlags, resolveToolchain };
|