Skip to content

Commit 8d3ed03

Browse files
committed
fix(pathfinder): change found_via from "CUDA_HOME" to "CUDA_PATH"
Aligns the provenance label with the new CUDA_PATH-first priority. The label signals the highest-priority env var name, not necessarily which variable supplied the value. Discovered via independent review from GPT-5.4 Extra High Made-with: Cursor
1 parent 6d065e9 commit 8d3ed03

11 files changed

Lines changed: 26 additions & 16 deletions

File tree

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class LoadedDL:
2828
abs_path: str | None
2929
was_already_loaded_from_elsewhere: bool
3030
_handle_uint: int # Platform-agnostic unsigned pointer value
31-
found_via: str
31+
found_via: str # "CUDA_PATH" covers both CUDA_PATH and CUDA_HOME env vars
3232

3333

3434
def load_dependencies(desc: LibDescriptor, load_func: Callable[[str], LoadedDL]) -> None:

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,23 @@ def find_in_conda(ctx: SearchContext) -> FindResult | None:
183183

184184

185185
def find_in_cuda_home(ctx: SearchContext) -> FindResult | None:
186-
"""Search ``$CUDA_HOME`` / ``$CUDA_PATH``.
186+
"""Search ``$CUDA_PATH`` / ``$CUDA_HOME``.
187187
188188
On Windows, this is the normal fallback for system-installed CTK DLLs when
189189
they are not already discoverable via the native ``LoadLibraryExW(..., 0)``
190190
path used by :func:`cuda.pathfinder._dynamic_libs.load_dl_windows.load_with_system_search`.
191191
Python 3.8+ does not include ``PATH`` in that native DLL search.
192+
193+
The returned ``found_via`` is always ``"CUDA_PATH"`` regardless of which
194+
environment variable actually provided the value.
192195
"""
193196
cuda_home = get_cuda_path_or_home()
194197
if cuda_home is None:
195198
return None
196199
lib_dir = _find_lib_dir_using_anchor(ctx.desc, ctx.platform, cuda_home)
197200
abs_path = _find_using_lib_dir(ctx, lib_dir)
198201
if abs_path is not None:
199-
return FindResult(abs_path, "CUDA_HOME")
202+
return FindResult(abs_path, "CUDA_PATH")
200203
return None
201204

202205

cuda_pathfinder/cuda/pathfinder/_headers/find_nvidia_headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def find_in_cuda_home(desc: HeaderDescriptor) -> LocatedHeaderDir | None:
107107
return None
108108
result = _locate_in_anchor_layout(desc, cuda_home)
109109
if result is not None:
110-
return LocatedHeaderDir(abs_path=result, found_via="CUDA_HOME")
110+
return LocatedHeaderDir(abs_path=result, found_via="CUDA_PATH")
111111
return None
112112

113113

cuda_pathfinder/cuda/pathfinder/_static_libs/find_bitcode_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def locate_bitcode_lib(name: str) -> LocatedBitcodeLib:
145145
name=name,
146146
abs_path=abs_path,
147147
filename=finder.filename,
148-
found_via="CUDA_HOME",
148+
found_via="CUDA_PATH",
149149
)
150150

151151
finder.raise_not_found_error()

cuda_pathfinder/cuda/pathfinder/_static_libs/find_static_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def locate_static_lib(name: str) -> LocatedStaticLib:
149149
name=name,
150150
abs_path=abs_path,
151151
filename=finder.filename,
152-
found_via="CUDA_HOME",
152+
found_via="CUDA_PATH",
153153
)
154154

155155
finder.raise_not_found_error()

cuda_pathfinder/docs/source/release/1.5.0-notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Breaking Change
1515
a warning will be issued and ``CUDA_PATH`` will be used. This change aligns
1616
with industry standards and NVIDIA's recommended practices.
1717

18+
The ``found_via`` provenance field on ``LoadedDL``, ``LocatedHeaderDir``,
19+
``LocatedStaticLib``, and ``LocatedBitcodeLib`` now reports ``"CUDA_PATH"``
20+
(previously ``"CUDA_HOME"``) when a library or header was discovered through
21+
the ``CUDA_PATH``/``CUDA_HOME`` environment variables. The label reflects
22+
the highest-priority variable name, not necessarily the variable that
23+
supplied the value.
24+
1825
**Migration Guide**:
1926

2027
- If you rely on ``CUDA_HOME``, consider switching to ``CUDA_PATH``

cuda_pathfinder/tests/test_ctk_root_discovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def test_cuda_home_takes_priority_over_canary(tmp_path, mocker):
424424
result = _load_lib_no_cache("nvvm")
425425

426426
# CUDA_HOME must win; the canary should never have been consulted
427-
assert result.found_via == "CUDA_HOME"
427+
assert result.found_via == "CUDA_PATH"
428428
assert result.abs_path == str(nvvm_home_lib)
429429
canary_mock.assert_not_called()
430430

cuda_pathfinder/tests/test_find_bitcode_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _located_bitcode_lib_asserts(located_bitcode_lib):
5454
assert isinstance(located_bitcode_lib.abs_path, str)
5555
assert isinstance(located_bitcode_lib.filename, str)
5656
assert isinstance(located_bitcode_lib.found_via, str)
57-
assert located_bitcode_lib.found_via in ("site-packages", "conda", "CUDA_HOME")
57+
assert located_bitcode_lib.found_via in ("site-packages", "conda", "CUDA_PATH")
5858
assert os.path.isfile(located_bitcode_lib.abs_path)
5959

6060

@@ -110,7 +110,7 @@ def test_locate_bitcode_lib_search_order(monkeypatch, tmp_path):
110110

111111
located_lib = locate_bitcode_lib("device")
112112
assert located_lib.abs_path == cuda_home_path
113-
assert located_lib.found_via == "CUDA_HOME"
113+
assert located_lib.found_via == "CUDA_PATH"
114114

115115

116116
@pytest.mark.usefixtures("clear_find_bitcode_lib_cache")

cuda_pathfinder/tests/test_find_nvidia_headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _located_hdr_dir_asserts(located_hdr_dir):
5656
assert located_hdr_dir.found_via in (
5757
"site-packages",
5858
"conda",
59-
"CUDA_HOME",
59+
"CUDA_PATH",
6060
"system-ctk-root",
6161
"supported_install_dir",
6262
)
@@ -201,7 +201,7 @@ def test_locate_ctk_headers_cuda_home_takes_priority_over_canary(tmp_path, monke
201201

202202
assert located_hdr_dir is not None
203203
assert located_hdr_dir.abs_path == expected_hdr_dir
204-
assert located_hdr_dir.found_via == "CUDA_HOME"
204+
assert located_hdr_dir.found_via == "CUDA_PATH"
205205
probe.assert_not_called()
206206

207207

cuda_pathfinder/tests/test_find_static_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _located_static_lib_asserts(located_static_lib):
5151
assert isinstance(located_static_lib.abs_path, str)
5252
assert isinstance(located_static_lib.filename, str)
5353
assert isinstance(located_static_lib.found_via, str)
54-
assert located_static_lib.found_via in ("site-packages", "conda", "CUDA_HOME")
54+
assert located_static_lib.found_via in ("site-packages", "conda", "CUDA_PATH")
5555
assert os.path.isfile(located_static_lib.abs_path)
5656

5757

@@ -114,7 +114,7 @@ def test_locate_static_lib_search_order(monkeypatch, tmp_path):
114114

115115
located_lib = locate_static_lib("cudadevrt")
116116
assert located_lib.abs_path == cuda_home_path
117-
assert located_lib.found_via == "CUDA_HOME"
117+
assert located_lib.found_via == "CUDA_PATH"
118118

119119

120120
@pytest.mark.usefixtures("clear_find_static_lib_cache")

0 commit comments

Comments
 (0)