Skip to content

Commit acfe5f1

Browse files
committed
refactor(pathfinder): apply review feedback on binary finder
- Rename _is_executable_file to _is_executable_candidate; the helper marks a return candidate rather than proving OS executability. Drop its docstring now that the name is self-explanatory, and update the test patch target. - Drop the 'ambient PATH is never consulted' sentence from resolve_ctk_root_via_canary; it is not universally true. Signed-off-by: Aryan <[email protected]>
1 parent c28e7b2 commit acfe5f1

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

‎cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ def _normalize_utility_name(utility_name: str) -> str:
2828
return utility_name
2929

3030

31-
def _is_executable_file(path: str) -> bool:
32-
"""Return True if ``path`` is a file the OS would run as an executable.
33-
34-
On Windows executability is determined by the file extension (the
35-
candidate name already carries one), so existence is sufficient. On POSIX
36-
the execute permission bit must be set.
37-
"""
31+
def _is_executable_candidate(path: str) -> bool:
3832
if not os.path.isfile(path):
3933
return False
4034
if IS_WINDOWS:
@@ -68,7 +62,7 @@ def _resolve_in_trusted_dirs(normalized_name: str, dirs: list[str]) -> str | Non
6862
assert directory
6963
seen.add(directory)
7064
candidate = os.path.join(directory, normalized_name)
71-
if _is_executable_file(candidate):
65+
if _is_executable_candidate(candidate):
7266
return candidate
7367
return None
7468

‎cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def resolve_ctk_root_via_canary(canary_libname: str) -> str | None:
143143
an isolated subprocess, which honors ``LD_LIBRARY_PATH`` on Linux and the
144144
native DLL search on Windows. The toolkit root is then derived from that
145145
path. Returns ``None`` if the canary cannot be resolved or no root can be
146-
derived. The ambient ``PATH`` is never consulted.
146+
derived.
147147
"""
148148
canary_abs_path = _resolve_system_loaded_abs_path_in_subprocess(canary_libname)
149149
if canary_abs_path is None:

‎cuda_pathfinder/tests/test_find_nvidia_binaries.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def _patch_exec_probe(mocker, existing=()):
5050
existing = set(existing)
5151
checked: list[str] = []
5252

53-
def fake_is_executable_file(path):
53+
def fake_is_executable_candidate(path):
5454
checked.append(path)
5555
return path in existing
5656

57-
mocker.patch.object(binary_finder_module, "_is_executable_file", side_effect=fake_is_executable_file)
57+
mocker.patch.object(binary_finder_module, "_is_executable_candidate", side_effect=fake_is_executable_candidate)
5858
return checked
5959

6060

0 commit comments

Comments
 (0)