From e3311adadefbcdd9ba21b803776380539ac13320 Mon Sep 17 00:00:00 2001 From: Emery Conrad Date: Mon, 31 Aug 2026 18:10:37 -0500 Subject: [PATCH] test: pass PYTHONPATH to the test52 subprocess The child process starts with no env of its own. rules_python builds the runner's sys.path in-process through its bootstrap, so the child cannot import cppjit when the package is a consumer's external bazel module. The CMake lanes export PYTHONPATH, which masked the gap. Co-developed-with-the-help-of: Claude Code (Fable 5, human in the loop) --- test/test_regression.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_regression.py b/test/test_regression.py index 2d9fa20..df90a6d 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -1648,6 +1648,7 @@ def test52_str_fallback_without_ostream_insertion(self): output identifies which failure happened. """ + import os import subprocess import sys @@ -1658,8 +1659,15 @@ def test52_str_fallback_without_ostream_insertion(self): print(repr(str(cppjit.gbl.StrFallback.Bare()))) """ + # A build system can put cppjit on sys.path without PYTHONPATH (bazel + # gives the runner a bootstrap instead), so hand the child this + # process's own path. + env = dict(os.environ) + env["PYTHONPATH"] = os.pathsep.join(p for p in sys.path if p) + popen = subprocess.Popen( [sys.executable, "-c", repro], + env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, )