Repository navigation
fix(selftest): make the pinned-gate-tests python shim an exec wrapper - #293
Merged
Merged
Conversation
_run_action() made shim/python a symlink to sys.executable. Started through a symlink, CPython keeps the symlink's path as sys._base_executable, so venv wrote `home = <tmp>/shim` and the new venv's python could find its stdlib only by fallback. CI's setup-python falls back to a compile-time prefix that is its real install. uv's python-build-standalone builds without astral-sh/python-build-standalone#896 (cpython 3.13.9, for one) fall back to /install and die with "No module named 'encodings'", so 11 of 25 cases failed on every local macOS run, and on Linux with that build too. - _write_python_shim() writes `#!/bin/sh` + `exec <realpath of sys.executable> "$@"`, so venv records the real bin dir as home. - _run_action() checks every venv the action built: home is not the shim's directory, and the python in home is this interpreter. CI masks the bug, so this check is what fails there if a symlink comes back, in the helper or at the call site. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No issues found. Small, well-reasoned fix replacing a symlink shim with an exec wrapper; the new assertion correctly checks the invariant it's meant to enforce. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS,
uv run pytest selftest/test_pinned_gate_tests_action.pyfails 11 of 25 tests on every local run. That includes a cleanorigin/main(2815beb).Tests (Python)passes on CI. Every failure is the same error:_run_action()madeshim/pythona symlink tosys.executableand putshim/first on PATH. That makes the action's barepython -I -m venv "$venv"run the test's interpreter.When CPython starts through a symlink (outside a macOS framework build), it keeps the symlink's own path as
sys._base_executable. Sovenvwriteshome = <tmp>/shiminto the new venv'spyvenv.cfg. That directory has no stdlib. The new venv's python looks for its stdlib starting fromhome, finds none there, and falls back:setup-python; Dockerpython:3.13(/usr/local)/installCould not find platform independent libraries <prefix>, thenNo module named 'encodings', so ensurepip exits 1So the bug is not specific to macOS. uv's cpython 3.13.9 fails the same 11 tests on Linux too.
Fix
_write_python_shim()writesshim/pythonas#!/bin/sh+exec <realpath of sys.executable> "$@", with the pathshlex.quoted. The interpreter starts from its real path, sovenvrecords the real bin directory ashome. No fallback is involved..venv: itspyvenv.cfglookup happened next to the shim. Only the path venv sees has changed._run_action()now checks every venv the action built.homeis not the shim's directory, and that the python inhomeis this interpreter./opt/homebrew/opt/python@3.13/binashomewhatever path it starts through, and that is correct there._run_action's own call.venv/pyvenv.cfgwith no existence check, so if the action's layout changes the check fails loudly instead of being skipped.The action itself is unchanged, and so are all existing assertions. The suite still has 25 tests.
Verification
All runs below are of the whole file. A mutant is the fixed file with the shim reverted to a symlink, in the helper or at
_run_action's call.origin/mainpython:3.13, arm64),/usr/local3.13.16, standing in forsetup-pythonvenv home is the python shim's dir. The 10 cases that still pass are input validation and structural checks; none of them builds a venv.FileNotFoundErroron the missingpyvenv.cfg).ruff format --checkandruff checkare clean.uv sync --frozen --all-extrasanduv run --no-sync pytest, likeTests (Python)does._run_action's own call. The check now runs in_run_action.Not changed here: on
origin/main, four must-fail cases passed on macOS only because the venv build failed:test_ungated_recursive_delete_failsand three rows oftest_count_cases_fail. They now fail at the new check instead. They still assert onlyrc != 0, so a failure after a good venv build would still satisfy them (pip unable to install from the wheelhouse, for example). Tightening them is a separate change.Auto-merge rationale: none. This is a manual merge, as for every topcoder1/ci-workflows PR (no automerge lane is wired on this repo). The diff is selftest-only (
safe_test).🤖 Generated with Claude Code