Skip to content

Commit b702b7a

Browse files
committed
fix(pathfinder): anchor canary probe import root
Run the canary subprocess from the parent package's import root so wheel-based CI tests do not accidentally resolve `cuda.pathfinder` from the checkout tree and fail on missing generated files. Made-with: Cursor
1 parent 3f36149 commit b702b7a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import struct
99
import subprocess
1010
import sys
11+
from pathlib import Path
1112
from typing import TYPE_CHECKING
1213

1314
from cuda.pathfinder._dynamic_libs.lib_descriptor import LIB_DESCRIPTORS
@@ -41,6 +42,7 @@
4142
_PLATFORM_NAME = "Windows" if IS_WINDOWS else "Linux"
4243
_CANARY_PROBE_MODULE = "cuda.pathfinder._dynamic_libs.canary_probe_subprocess"
4344
_CANARY_PROBE_TIMEOUT_SECONDS = 10.0
45+
_CANARY_PROBE_IMPORT_ROOT = Path(__file__).resolve().parents[3]
4446

4547
# Driver libraries: shipped with the NVIDIA display driver, always on the
4648
# system linker path. These skip all CTK search steps (site-packages,
@@ -102,6 +104,7 @@ def _resolve_system_loaded_abs_path_in_subprocess(libname: str) -> str | None:
102104
text=True,
103105
timeout=_CANARY_PROBE_TIMEOUT_SECONDS,
104106
check=False,
107+
cwd=_CANARY_PROBE_IMPORT_ROOT,
105108
)
106109
except subprocess.TimeoutExpired as exc:
107110
_raise_canary_probe_child_process_error(timeout=exc.timeout, stderr=exc.stderr)

cuda_pathfinder/tests/test_ctk_root_discovery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
_MODULE = "cuda.pathfinder._dynamic_libs.load_nvidia_dynamic_lib"
3232
_STEPS_MODULE = "cuda.pathfinder._dynamic_libs.search_steps"
33-
_PACKAGE_ROOT = Path(__file__).resolve().parents[1]
33+
_PACKAGE_ROOT = Path(load_mod.__file__).resolve().parents[3]
3434

3535

3636
def _ctx(libname: str = "nvvm") -> SearchContext:
@@ -206,6 +206,7 @@ def test_subprocess_probe_returns_abs_path_on_string_payload(mocker):
206206
text=True,
207207
timeout=10.0,
208208
check=False,
209+
cwd=_PACKAGE_ROOT,
209210
)
210211

211212

0 commit comments

Comments
 (0)