Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions cuda_pathfinder/cuda/pathfinder/_utils/resolve_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
8 changes: 4 additions & 4 deletions cuda_pathfinder/tests/test_utils_resolve_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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
Expand Down
Loading