Repository navigation
Commit e559532
authored
fix(release): resolve an interpreter that has tomllib (#58)
* fix(release): resolve an interpreter that has tomllib
`./scripts/release.sh prepare minor` fails outright on macOS:
ModuleNotFoundError: No module named 'tomllib'
tomllib is stdlib only from 3.11, and `python3` on macOS is 3.9. Every helper
in the script -- get_version, get_pkg_name, set_version, bump_version, the
changelog update, and the publish-time changelog check -- hardcoded `python3`,
so releasing this package was impossible on such a machine. The error names a
missing module, which reads as a broken checkout rather than a too-old
interpreter.
Resolved once at load time instead of per call site: `python3` when it can
actually import tomllib, else `uv run`, else a message that says what is
needed and what was found. uv is the right fallback because this repo already
builds and tests through it, so a machine that can run the suite can run the
release.
The two `need python3` guards are dropped as redundant -- resolve_python has
already exited with a better message by then.
Verified under bash, which is how the script runs:
PY_BIN=uv run --no-project --python 3.12 python
version=0.10.0 pkg=hotdata-framework
minor=0.11.0 patch=0.10.1 major=1.0.0
and with no usable interpreter on PATH:
error: need python3 >= 3.11 (for tomllib) or uv; python3 is Python 3.9.6
No behaviour change to what a release does -- only which interpreter runs it.
Note the same hardcoded `python3 - <<PY` + tomllib pattern is in sdk-python's
and hotdata-marimo's copies of this script, so both are latently broken the
same way on a pre-3.11 `python3`. Not touched here.
* fix(release): resolve lazily, and do not swallow the not-found message
Resolving at load time made the interpreter a hard requirement for every
invocation, including the ones that never run Python. On a machine with
python3 3.9 and no uv, `--help` died with the interpreter error instead of
printing usage -- so the message telling you which interpreter you need was
itself gated on having it, on exactly the machine the resolution exists for.
Now resolved as the first line of cmd_prepare and cmd_publish, with an empty
default for set -u.
And `$(python3 -V 2>&1 || echo absent)` captured the shell's own
"command not found" into the message before appending "absent", so the
no-python3-at-all case printed both. Guarded on command -v.
Verified: --help prints usage with PATH=/usr/bin:/bin; prepare/publish still
refuse with `python3 is Python 3.9.6`; and with python3 entirely absent the
message is `python3 is absent`.1 parent d1d6a1c commit e559532
1 file changed
Lines changed: 33 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
10 | 35 | | |
11 | 36 | | |
12 | 37 | | |
| |||
24 | 49 | | |
25 | 50 | | |
26 | 51 | | |
27 | | - | |
| 52 | + | |
28 | 53 | | |
29 | 54 | | |
30 | 55 | | |
31 | 56 | | |
32 | 57 | | |
33 | 58 | | |
34 | 59 | | |
35 | | - | |
| 60 | + | |
36 | 61 | | |
37 | 62 | | |
38 | 63 | | |
| |||
41 | 66 | | |
42 | 67 | | |
43 | 68 | | |
44 | | - | |
| 69 | + | |
45 | 70 | | |
46 | 71 | | |
47 | 72 | | |
| |||
56 | 81 | | |
57 | 82 | | |
58 | 83 | | |
59 | | - | |
| 84 | + | |
60 | 85 | | |
61 | 86 | | |
62 | 87 | | |
| |||
95 | 120 | | |
96 | 121 | | |
97 | 122 | | |
98 | | - | |
| 123 | + | |
99 | 124 | | |
100 | 125 | | |
101 | 126 | | |
| 127 | + | |
102 | 128 | | |
103 | 129 | | |
104 | 130 | | |
105 | | - | |
106 | 131 | | |
107 | 132 | | |
108 | 133 | | |
| |||
150 | 175 | | |
151 | 176 | | |
152 | 177 | | |
| 178 | + | |
153 | 179 | | |
154 | | - | |
155 | 180 | | |
156 | 181 | | |
157 | 182 | | |
| |||
166 | 191 | | |
167 | 192 | | |
168 | 193 | | |
169 | | - | |
| 194 | + | |
170 | 195 | | |
171 | 196 | | |
172 | 197 | | |
| |||
0 commit comments