Skip to content

Commit b4e928c

Browse files
committed
fixup! feat(core.utils): forward sys.path to subprocess in lightweight-import test
1 parent f9f1693 commit b4e928c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

cuda_core/tests/test_program_cache.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def test_cuda_core_utils_memoryview_import_is_lightweight():
117117
import the program-cache backends; the cache modules pull in extra
118118
driver/NVRTC machinery that memoryview-only consumers have no reason
119119
to load."""
120+
import os
120121
import subprocess
121122
import sys
122123
import textwrap
@@ -134,7 +135,12 @@ def test_cuda_core_utils_memoryview_import_is_lightweight():
134135
_ = u.make_program_cache_key
135136
assert "cuda.core.utils._program_cache" in sys.modules
136137
""")
137-
subprocess.run([sys.executable, "-c", prog], check=True) # noqa: S603
138+
# Forward pytest's sys.path to the subprocess via PYTHONPATH so it can
139+
# find the same cuda.core install the parent process is using (CI runs
140+
# may rely on pytest-added rootdirs that env-only inheritance misses).
141+
env = os.environ.copy()
142+
env["PYTHONPATH"] = os.pathsep.join(p for p in sys.path if p)
143+
subprocess.run([sys.executable, "-c", prog], check=True, env=env) # noqa: S603
138144

139145

140146
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)