Skip to content

Commit 2841734

Browse files
committed
Replace find_sub_dirs with glob.glob for simplicity. Functionally equivalent.
1 parent 7498392 commit 2841734

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/find_nvidia_dynamic_lib.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
is_suppressed_dll_file,
1515
)
1616
from cuda.pathfinder._utils.env_vars import get_cuda_home_or_path
17-
from cuda.pathfinder._utils.find_sub_dirs import find_sub_dirs, find_sub_dirs_all_sitepackages
17+
from cuda.pathfinder._utils.find_sub_dirs import find_sub_dirs_all_sitepackages
1818
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS
1919

2020

@@ -81,27 +81,30 @@ def _find_dll_using_nvidia_bin_dirs(
8181

8282

8383
def _find_lib_dir_using_anchor_point(libname: str, anchor_point: str, linux_lib_dir: str) -> Optional[str]:
84-
subdirs_list: tuple[tuple[str, ...], ...]
84+
# Resolve paths for the four cases:
85+
# Windows/Linux x nvvm yes/no
8586
if IS_WINDOWS:
8687
if libname == "nvvm": # noqa: SIM108
87-
subdirs_list = (
88-
("nvvm", "bin", "*"), # CTK 13
89-
("nvvm", "bin"), # CTK 12
90-
)
88+
rel_paths = [
89+
"nvvm/bin/*", # CTK 13
90+
"nvvm/bin", # CTK 12
91+
]
9192
else:
92-
subdirs_list = (
93-
("bin", "x64"), # CTK 13
94-
("bin",), # CTK 12
95-
)
93+
rel_paths = [
94+
"bin/x64", # CTK 13
95+
"bin", # CTK 12
96+
]
9697
else:
9798
if libname == "nvvm": # noqa: SIM108
98-
subdirs_list = (("nvvm", "lib64"),)
99+
rel_paths = ["nvvm/lib64"]
99100
else:
100-
subdirs_list = ((linux_lib_dir,),)
101-
for sub_dirs in subdirs_list:
102-
dirname: str # work around bug in mypy
103-
for dirname in find_sub_dirs((anchor_point,), sub_dirs):
104-
return dirname
101+
rel_paths = [linux_lib_dir]
102+
103+
for rel_path in rel_paths:
104+
for dirname in sorted(glob.glob(os.path.join(anchor_point, rel_path))):
105+
if os.path.isdir(dirname):
106+
return dirname
107+
105108
return None
106109

107110

0 commit comments

Comments
 (0)