Skip to content

Commit 0e19a05

Browse files
rparolinclaude
andcommitted
test: stub the CTK lookup in the build-dir capture helper
The two TestGeneratedSourceDirIsKeyed cases call the real _build_cuda_core(), whose first statement resolves CUDA_PATH/CUDA_HOME for the compiler's include dirs. The helper stubbed cythonize() but not that lookup, so both tests failed on every (wheels) CI job -- those install a prebuilt wheel and deliberately have no toolkit present: RuntimeError: Environment variable CUDA_PATH or CUDA_HOME is not set Nothing in these tests needs a real toolkit. cythonize() is replaced so no C++ is generated or compiled, the path is only string-joined into include_dirs and never dereferenced, and the CUDA major comes from the CUDA_CORE_BUILD_MAJOR env var the helper already sets, which _determine_cuda_major_version() returns from before reading cuda.h. Stub _get_cuda_path rather than dropping the call: it must stay first so the cuda.pathfinder import repairs PEP 517 namespace shadowing before cuda.bindings is imported, which test_cuda_path_is_resolved_before_importing_bindings pins. That test is also the precedent here -- it calls _build_cuda_core() and stubs the same function, which is why it has been green in the wheels jobs all along. Verified by reproducing the wheels condition with CUDA_PATH and CUDA_HOME unset: 2 failed before, 23 passed after, and 23 passed with them set. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 98a662e commit 0e19a05

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

cuda_core/tests/test_build_hooks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def fake_cythonize(ext_modules, **kwargs):
226226
captured.update(kwargs)
227227
return []
228228

229+
# Builds resolve the CTK for include dirs; stub it so the test runs
230+
# where no toolkit is installed (e.g. the wheels CI jobs).
231+
monkeypatch.setattr(build_hooks, "_get_cuda_path", lambda: "/nonexistent-cuda")
229232
monkeypatch.setattr(build_hooks, "cythonize", fake_cythonize)
230233
monkeypatch.setenv("CUDA_CORE_BUILD_MAJOR", cuda_major)
231234
build_hooks._determine_cuda_major_version.cache_clear()

0 commit comments

Comments
 (0)