From 80a5c3cdb6390c545db576eef5d006a3d7129435 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN Date: Thu, 20 Aug 2026 09:56:37 -0400 Subject: [PATCH] Locate the test interpreter via pythonLocation, not just PATH names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous attempt failed loudly with the resolved paths, which is what it was built to do, and they said the rest: on Windows BOTH `python` and `python3` are MSYS2's. The toolchain that must be on PATH so native wheels can build is the very thing hiding the interpreter the tests need, and no bare name can reach past it. setup-python exports `pythonLocation` (here C:\hostedtoolcache\...\3.10.11) without necessarily putting it first on PATH, so that is now tried before the bare names, along with a last-resort candidate derived from wherever `pytest` itself resolves — the determinism gate proves that one is reachable on this runner. Selection is still by capability: the first candidate that can actually import pytest wins, and a total failure prints every path it tried. It also now echoes the interpreter it chose, so the next surprise of this kind is one line of log rather than a deduction. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01Vtx94nXDmNgXEeThUZP4QN --- scripts/run_ci_tests.sh | 46 +++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/scripts/run_ci_tests.sh b/scripts/run_ci_tests.sh index 810800da..483d7ba3 100755 --- a/scripts/run_ci_tests.sh +++ b/scripts/run_ci_tests.sh @@ -13,23 +13,37 @@ fi # bare `python` resolved to that one and the whole suite died with "No module # named pytest", after the determinism gate had already passed using the # `pytest` executable, which MSYS2 does not provide. -if [[ -x ".venv/bin/python" ]]; then - py_bin=".venv/bin/python" -else - py_bin="" - for candidate in python python3; do - if command -v "$candidate" >/dev/null 2>&1 \ - && "$candidate" -c "import pytest" >/dev/null 2>&1; then - py_bin="$candidate" - break - fi - done - if [[ -z "$py_bin" ]]; then - echo "no interpreter on PATH can import pytest" >&2 - command -v python python3 >&2 || true - exit 1 - fi +candidates=() +[[ -x ".venv/bin/python" ]] && candidates+=(".venv/bin/python") +# setup-python exports pythonLocation but does not necessarily put it first on +# PATH. On Windows the MSYS2 toolchain is prepended so native wheels can +# build, and it ships its own python.exe AND python3 -- so BOTH bare names +# resolve to an interpreter with no pytest, and the toolchain that has to be +# on PATH is the very thing that hides the interpreter we want. +if [[ -n "${pythonLocation:-}" ]]; then + candidates+=("${pythonLocation}/python" "${pythonLocation}/python.exe" "${pythonLocation}/bin/python") fi +candidates+=(python python3) +# Last resort: pytest itself is resolvable here (the determinism gate runs it +# that way), so its own directory locates a usable interpreter. +if command -v pytest >/dev/null 2>&1; then + pytest_dir="$(dirname "$(command -v pytest)")" + candidates+=("$pytest_dir/python" "$pytest_dir/python.exe" "$pytest_dir/../python" "$pytest_dir/../python.exe") +fi + +py_bin="" +for candidate in "${candidates[@]}"; do + if "$candidate" -c "import pytest" >/dev/null 2>&1; then + py_bin="$candidate" + break + fi +done +if [[ -z "$py_bin" ]]; then + echo "no interpreter can import pytest; tried:" >&2 + printf ' %s\n' "${candidates[@]}" >&2 + exit 1 +fi +echo "test interpreter: $py_bin" if [[ "${DETERMINISM_GATE:-1}" == "1" ]]; then ./scripts/run_determinism_tests.sh