Repository navigation
Launchers: skip a python3 older than the bootstrap needs - #194
Carlos Savcic (serverleader) wants to merge 3 commits into
Conversation
On macOS the first python3 on a hook's PATH is often /usr/bin/python3 (3.9): agents run hooks without a login shell, so Homebrew or pyenv Pythons come later or only under a versioned name. The POSIX launchers exec'd that first python3, the bootstrap failed open on its version check, and the plugin silently did nothing although a usable Python was installed. Probe each candidate (TE_PYTHON, python3, python3.14 .. python3.10, python) and exec the first one >= 3.10. With none, hand the hook to the first Python found so the bootstrap still fails open, and `te` still says which version it needs. Windows paths are unchanged.
|
Carlos Savcic (@serverleader) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Muhammad Abdullah Butt (1AbdullahButt)
left a comment
There was a problem hiding this comment.
I read both launchers at the PR head next to te_bootstrap.py (which stays importable by any Python 3 so it can answer {} itself). The probe-then-fallback order looks right for the macOS /usr/bin/python3 case. A few edge cases in the new loop (plugin/scripts/te-hook:42-50, and the same lines in plugin/scripts/te):
-
oldis set even when the candidate didn't run at all. The probe exits 1 for a Python that is too old, but a pyenv/asdf shim with no version selected (pyenv: python3: command not found, exit 127) or a dangling link also lands inold=$py. If that's the only candidate, the fallbackexecs it, so the hook prints an error and no JSON instead of reaching the builtin{}at the end of the script. Recording only real old interpreters keeps the fail-open path:"$py" -c 'import sys; sys.exit(sys.version_info < (3, 10))' </dev/null >/dev/null 2>&1 rc=$? [ "$rc" -eq 0 ] && exec "$py" "$dir/te_bootstrap.py" hook "$@" [ "$rc" -eq 1 ] && [ -z "$old" ] && old=$py
-
An explicit
TE_PYTHONthat is too old is now silently skipped. Onmain,TE_PYTHONalways won. Now a laterpython3.12on PATH is used instead, and the "set TE_PYTHON" message inteno longer describes what happened. If that's intended, a line in the comment would help. If not,[ "$py" = "${TE_PYTHON:-}" ] && exec ...before the probe keeps the override authoritative. -
python3.15is missing from the list. 3.15.0 shipped in October, so a freshbrew install python@3.15that isn't linked aspython3would be passed over. The list will keep ageing, so addingpython3.15now (and maybe a note to extend it) is cheap.
The two new tests cover the skip and the old-only fallback. A third case with a candidate that exits 127 would pin point 1.
Reviewed with help from Claude Code.
TE_PYTHON is the person's choice and runs without a version probe, as before. The probe skips site setup. The fallback test's PATH no longer includes /bin, whose real python3.x made it fail on Linux.
A pyenv shim with no version set exits 127; it is no longer kept as the too-old fallback, so with no other Python the hook still answers {}. Raised in review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Aaron Li (aaron-jx-li)
left a comment
There was a problem hiding this comment.
Carlos Savcic (@serverleader) Hi, please sign the CLA so we can merge your code
Problem
On macOS the first
python3on a hook's PATH is often/usr/bin/python3(3.9). Agents run hooks without a login shell, so Homebrew/pyenv Pythons come later on PATH or only under a versioned name (python3.12). The POSIX branch ofte-hook/teexec'd that firstpython3,te_bootstrap.pyfailed open onMIN_VERSION, and the plugin silently did nothing even though a usable Python was installed.Change
POSIX branch only (Windows paths untouched):
TE_PYTHON,python3,python3.14…python3.10,python) and exec the first one >= 3.10.testill prints "needs Python >= 3.10; set TE_PYTHON".Cost: one extra
python -cper launch on the POSIX path.Tests
Two tests in
tests/test_plugin_package.py:test_the_launcher_skips_a_python3_older_than_the_bootstrap_needs: fails onmain, passes here.test_with_only_an_old_python_the_launcher_still_hands_it_the_hook: guards the fallback.Full suite on macOS / Python 3.14: 852 passed, 16 skipped.