diff --git a/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py b/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py index 8a0826e1d96..12944ca22ea 100644 --- a/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py +++ b/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py @@ -57,7 +57,7 @@ def _resolve_candidate_paths(candidates: Iterable[str]) -> str | None: continue seen.add(candidate) if _is_executable_candidate(candidate): - return str(resolve_path(candidate)) + return resolve_path(candidate) return None diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py index 73eef6fc226..ec21abb9bd0 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py @@ -54,7 +54,7 @@ def _iter_lib_dirs(root: str, rel_dirs: tuple[str, ...]) -> Iterator[str]: for rel_path in rel_dirs: for dirname in sorted(glob.glob(os.path.join(root, rel_path))): if os.path.isdir(dirname): - yield str(resolve_path(dirname)) + yield resolve_path(dirname) def _find_under_root( @@ -192,7 +192,7 @@ def find_in_program_files_roots(ctx: SearchContext) -> FindResult | NotFound: for root in sorted(glob.glob(root_glob), key=numeric_aware_path_sort_key, reverse=True): if not os.path.isdir(root): continue - result = _find_under_anchor_root(ctx, str(resolve_path(root)), FOUND_VIA_PROGRAM_FILES) + result = _find_under_anchor_root(ctx, resolve_path(root), FOUND_VIA_PROGRAM_FILES) if result.found: return result missed += result diff --git a/cuda_pathfinder/cuda/pathfinder/_headers/find_nvidia_headers.py b/cuda_pathfinder/cuda/pathfinder/_headers/find_nvidia_headers.py index 919f52d883c..84a45996614 100644 --- a/cuda_pathfinder/cuda/pathfinder/_headers/find_nvidia_headers.py +++ b/cuda_pathfinder/cuda/pathfinder/_headers/find_nvidia_headers.py @@ -58,7 +58,7 @@ def __post_init__(self) -> None: def _abs_norm(path: str | None) -> str | None: if path: - return str(resolve_path(path)) + return resolve_path(path) return None diff --git a/cuda_pathfinder/cuda/pathfinder/_static_libs/locate_file.py b/cuda_pathfinder/cuda/pathfinder/_static_libs/locate_file.py index 36cf85a1a9e..62f7b94b065 100644 --- a/cuda_pathfinder/cuda/pathfinder/_static_libs/locate_file.py +++ b/cuda_pathfinder/cuda/pathfinder/_static_libs/locate_file.py @@ -17,7 +17,7 @@ def _resolved_if_file(directory: Path | str, filename: str) -> str | None: file_path = Path(directory, filename) if file_path.is_file(): - return str(resolve_path(file_path)) + return resolve_path(file_path) return None diff --git a/cuda_pathfinder/cuda/pathfinder/_utils/resolve_path.py b/cuda_pathfinder/cuda/pathfinder/_utils/resolve_path.py index e562be19157..9acfe796cc3 100644 --- a/cuda_pathfinder/cuda/pathfinder/_utils/resolve_path.py +++ b/cuda_pathfinder/cuda/pathfinder/_utils/resolve_path.py @@ -5,6 +5,6 @@ from pathlib import Path -def resolve_path(*parts: str | os.PathLike[str]) -> Path: +def resolve_path(*parts: str | os.PathLike[str]) -> str: """Build a canonical absolute path, resolving symlinks and parent components.""" - return Path(*parts).resolve() + return str(Path(*parts).resolve()) diff --git a/cuda_pathfinder/tests/test_utils_resolve_path.py b/cuda_pathfinder/tests/test_utils_resolve_path.py index 9c41197a84c..28eac9fe104 100644 --- a/cuda_pathfinder/tests/test_utils_resolve_path.py +++ b/cuda_pathfinder/tests/test_utils_resolve_path.py @@ -19,9 +19,9 @@ def test_resolve_path_anchors_relative_parts(monkeypatch, tmp_path): target.touch() found = resolve_path("toolkit", Path("library.a")) - assert found == target.resolve() + assert found == str(target.resolve()) monkeypatch.chdir(tmp_path.parent) - assert found.is_file() + assert Path(found).is_file() @pytest.mark.skipif(os.name == "nt", reason="POSIX symlink parent traversal") @@ -35,7 +35,7 @@ def test_resolve_path_follows_symlink_before_parent(tmp_path): alias = tmp_path / "alias" alias.symlink_to(sdk / "leaf", target_is_directory=True) - assert resolve_path(alias, "..", "include", "header.h") == target.resolve() + assert resolve_path(alias, "..", "include", "header.h") == str(target.resolve()) @pytest.mark.skipif(os.name != "nt", reason="Windows drive-relative paths") @@ -59,7 +59,7 @@ def test_resolve_path_anchors_another_drive_current_directory(monkeypatch, tmp_p monkeypatch.chdir(tmp_path) assert Path.cwd().drive.casefold() != drive.casefold() found = resolve_path(drive + "toolkit", "library.a") - assert found == target.resolve() + assert found == str(target.resolve()) finally: subprocess.run( # noqa: S603 - remove only the temporary drive created by this test. [str(subst), drive, "/d"], check=True, capture_output=True