From 6fd9af7b87e7e5bb271293ea7db1921e0bc75f69 Mon Sep 17 00:00:00 2001 From: Oliver Meyer Date: Wed, 22 Apr 2026 16:58:47 +0200 Subject: [PATCH] fix(ci): prevent PYTHONHOME from leaking into nox sub-sessions on Windows On Windows, uv run sets PYTHONHOME to the managed Python 3.14 install directory. This leaks into nox sub-sessions for older Python versions (3.11-3.13), causing them to load 3.14's stdlib and crash at startup. Co-Authored-By: Claude Opus 4.6 --- noxfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/noxfile.py b/noxfile.py index 0d72f6aec..48f2040ed 100644 --- a/noxfile.py +++ b/noxfile.py @@ -893,6 +893,15 @@ def _run_test_suite(session: nox.Session, marker: str = "", cov_append: bool = F marker: Pytest marker expression cov_append: Whether to append to existing coverage data """ + # On Windows, uv run sets PYTHONHOME to the managed Python 3.14 install dir when it + # starts nox. This leaks into pytest sub-processes for older Python versions (3.11-3.13) + # and causes them to load Python 3.14's stdlib, crashing at startup. + # Fix: set PYTHONHOME to None in session.env so nox strips it from the subprocess + # environment entirely (nox._clean_env filters out None-valued entries before passing + # to subprocess.Popen). Unlike os.environ.pop(), this does NOT mutate global process + # state; it only affects subprocesses spawned by session.run() / session.run_install(). + if platform.system() == "Windows": + session.env["PYTHONHOME"] = None _setup_venv(session) posargs = session.posargs[:]