From 5d521f03495a3196a2642f55ccc2c7fddb117b1f Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Wed, 25 Nov 2026 12:36:30 -0700 Subject: [PATCH 1/2] refactor(pathfinder): remove four helpers that only their own tests call - `_iter_lib_dirs_using_anchor` and `_find_lib_dir_using_anchor` lost their last caller in #2680. - `SearchContext.libname` and `find_sub_dirs_sys_path` have no caller. The six tests removed here exercised only these helpers. The remaining tests still run every line of shipped code that they ran before. No behavior change: deletion only. 1645 passed, 6 skipped. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Rob Parolin --- .../pathfinder/_dynamic_libs/search_steps.py | 18 ------- .../cuda/pathfinder/_utils/find_sub_dirs.py | 4 -- cuda_pathfinder/tests/test_search_steps.py | 47 ------------------- .../tests/test_utils_find_sub_dirs.py | 6 --- 4 files changed, 75 deletions(-) diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py index 1511a9f98723..4e8c7a93b9de 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/search_steps.py @@ -55,10 +55,6 @@ class SearchContext: error_messages: list[str] = field(default_factory=list) attachments: list[str] = field(default_factory=list) - @property - def libname(self) -> str: - return self.desc.name # type: ignore[no-any-return] # mypy can't resolve new sibling module - @property def lib_searched_for(self) -> str: return cast(str, self.platform.lib_searched_for(self.desc)) @@ -81,20 +77,6 @@ def _iter_lib_dirs(root: str, rel_dirs: tuple[str, ...]) -> Iterator[str]: yield str(resolve_path(dirname)) -def _iter_lib_dirs_using_anchor( - desc: LibDescriptor, - platform: SearchPlatform, - anchor_point: str, -) -> Iterator[str]: - """Yield existing library directories under *anchor_point* in descriptor order.""" - yield from _iter_lib_dirs(anchor_point, platform.anchor_rel_dirs(desc)) - - -def _find_lib_dir_using_anchor(desc: LibDescriptor, platform: SearchPlatform, anchor_point: str) -> str | None: - """Find the first library directory under *anchor_point*.""" - return next(_iter_lib_dirs_using_anchor(desc, platform, anchor_point), None) - - def _find_using_lib_dir(ctx: SearchContext, lib_dir: str | None) -> str | None: """Find a library file in a resolved lib directory.""" if lib_dir is None: diff --git a/cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py b/cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py index 55705ba63935..fd4339ff527e 100644 --- a/cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py +++ b/cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py @@ -45,10 +45,6 @@ def find_sub_dirs(parent_dirs: Sequence[str], sub_dirs: Sequence[str]) -> list[s return find_sub_dirs_cached(tuple(parent_dirs), tuple(sub_dirs)) -def find_sub_dirs_sys_path(sub_dirs: Sequence[str]) -> list[str]: - return find_sub_dirs(sys.path, sub_dirs) - - def find_sub_dirs_all_sitepackages(sub_dirs: Sequence[str]) -> list[str]: parent_dirs = list(site.getsitepackages()) if site.ENABLE_USER_SITE: diff --git a/cuda_pathfinder/tests/test_search_steps.py b/cuda_pathfinder/tests/test_search_steps.py index 331564110361..a58e9c670c30 100644 --- a/cuda_pathfinder/tests/test_search_steps.py +++ b/cuda_pathfinder/tests/test_search_steps.py @@ -26,7 +26,6 @@ LATE_FIND_STEPS, FindResult, SearchContext, - _find_lib_dir_using_anchor, find_in_conda, find_in_cuda_path, find_in_install_root_env_vars, @@ -90,10 +89,6 @@ def _write_pe(path, machine): class TestSearchContext: - def test_libname_delegates_to_descriptor(self): - ctx = _ctx(_make_desc(name="nvrtc")) - assert ctx.libname == "nvrtc" - def test_lib_searched_for_linux(self): ctx = SearchContext(LIB_DESCRIPTORS["cublas"], platform=LinuxSearchPlatform()) assert ctx.lib_searched_for == "libcublas.so.13 or libcublas.so.12" @@ -1061,48 +1056,6 @@ def test_windows_anchor_dirs_select_x64(self): ) assert WindowsSearchPlatform(target_arch="x64").anchor_rel_dirs(desc) == ("bin/x64", "bin") - def test_find_lib_dir_uses_descriptor_linux(self, tmp_path): - (tmp_path / "nvvm" / "lib64").mkdir(parents=True) - - desc = _make_desc(name="nvvm", anchor_rel_dirs_linux=("nvvm/lib64",)) - result = _find_lib_dir_using_anchor(desc, LinuxSearchPlatform(), str(tmp_path)) - assert result is not None - assert result.endswith(os.path.join("nvvm", "lib64")) - - def test_find_lib_dir_uses_descriptor_windows(self, tmp_path): - (tmp_path / "nvvm" / "bin").mkdir(parents=True) - - desc = _make_desc( - name="nvvm", - anchor_rel_dirs_windows=WindowsSearchDirs( - x64=("nvvm/bin/x64", "nvvm/bin"), - arm64=("nvvm/bin/arm64", "nvvm/bin"), - ), - ) - result = _find_lib_dir_using_anchor(desc, WindowsSearchPlatform(target_arch="x64"), str(tmp_path)) - assert result is not None - assert result.endswith(os.path.join("nvvm", "bin")) - - @pytest.mark.agent_authored(model="gpt-5") - def test_find_lib_dir_windows_arm64_uses_arm64_anchor(self, tmp_path): - (tmp_path / "bin" / "x64").mkdir(parents=True) - (tmp_path / "bin" / "arm64").mkdir(parents=True) - - desc = _make_desc( - name="cudart", - anchor_rel_dirs_windows=WindowsSearchDirs( - x64=("bin/x64", "bin"), - arm64=("bin/arm64",), - ), - ) - result = _find_lib_dir_using_anchor(desc, WindowsSearchPlatform(target_arch="arm64"), str(tmp_path)) - assert result is not None - assert result.endswith(os.path.join("bin", "arm64")) - - def test_find_lib_dir_returns_none_when_no_match(self, tmp_path): - desc = _make_desc(anchor_rel_dirs_linux=("nonexistent",)) - assert _find_lib_dir_using_anchor(desc, LinuxSearchPlatform(), str(tmp_path)) is None - def test_nvvm_cuda_home_linux(self, mocker, tmp_path): """End-to-end: find_in_cuda_path resolves nvvm under its custom subdir.""" mocker.patch(f"{_STEPS_MOD}.get_cuda_path_or_home", return_value=str(tmp_path)) diff --git a/cuda_pathfinder/tests/test_utils_find_sub_dirs.py b/cuda_pathfinder/tests/test_utils_find_sub_dirs.py index 7714e8986499..7cd3f92d0dcb 100644 --- a/cuda_pathfinder/tests/test_utils_find_sub_dirs.py +++ b/cuda_pathfinder/tests/test_utils_find_sub_dirs.py @@ -8,7 +8,6 @@ from cuda.pathfinder._utils.find_sub_dirs import ( find_sub_dirs, find_sub_dirs_all_sitepackages, - find_sub_dirs_sys_path, ) NONEXISTENT = "NonExistentE12DBF1Fbe948337576B5F1E88f60bb2" @@ -81,11 +80,6 @@ def test_empty_sub_dirs(test_tree): assert sorted(result) == sorted(expected) -def test_find_sub_dirs_sys_path_no_math(): - result = find_sub_dirs_sys_path((NONEXISTENT,)) - assert result == [] - - def test_find_sub_dirs_all_sitepackages_no_match(): result = find_sub_dirs_all_sitepackages((NONEXISTENT,)) assert result == [] From cd491ac14107dd3d4bacfd8fee457c92e022c023 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 26 Nov 2026 11:17:25 -0800 Subject: [PATCH 2/2] ci: require manual copy-pr-bot approval Signed-off-by: Ralf W. Grosse-Kunstleve