1515
1616
1717@dataclass
18- class FoundHeaderDir :
18+ class LocatedHeaderDir :
1919 abs_path : str | None
2020 found_via : str
2121
@@ -33,16 +33,16 @@ def _joined_isfile(dirpath: str, basename: str) -> bool:
3333 return os .path .isfile (os .path .join (dirpath , basename ))
3434
3535
36- def _find_under_site_packages (sub_dir : str , h_basename : str ) -> FoundHeaderDir | None :
36+ def _locate_under_site_packages (sub_dir : str , h_basename : str ) -> LocatedHeaderDir | None :
3737 # Installed from a wheel
3838 hdr_dir : str # help mypy
3939 for hdr_dir in find_sub_dirs_all_sitepackages (tuple (sub_dir .split ("/" ))):
4040 if _joined_isfile (hdr_dir , h_basename ):
41- return FoundHeaderDir (abs_path = hdr_dir , found_via = "site-packages" )
41+ return LocatedHeaderDir (abs_path = hdr_dir , found_via = "site-packages" )
4242 return None
4343
4444
45- def _find_based_on_ctk_layout (libname : str , h_basename : str , anchor_point : str ) -> str | None :
45+ def _locate_based_on_ctk_layout (libname : str , h_basename : str , anchor_point : str ) -> str | None :
4646 parts = [anchor_point ]
4747 if libname == "nvvm" :
4848 parts .append (libname )
@@ -64,7 +64,7 @@ def _find_based_on_ctk_layout(libname: str, h_basename: str, anchor_point: str)
6464 return None
6565
6666
67- def _find_based_on_conda_layout (libname : str , h_basename : str , ctk_layout : bool ) -> FoundHeaderDir | None :
67+ def _find_based_on_conda_layout (libname : str , h_basename : str , ctk_layout : bool ) -> LocatedHeaderDir | None :
6868 conda_prefix = os .environ .get ("CONDA_PREFIX" )
6969 if not conda_prefix :
7070 return None
@@ -85,41 +85,41 @@ def _find_based_on_conda_layout(libname: str, h_basename: str, ctk_layout: bool)
8585 else :
8686 include_path = os .path .join (conda_prefix , "include" )
8787 anchor_point = os .path .dirname (include_path )
88- found_header_path = _find_based_on_ctk_layout (libname , h_basename , anchor_point )
88+ found_header_path = _locate_based_on_ctk_layout (libname , h_basename , anchor_point )
8989 if found_header_path :
90- return FoundHeaderDir (abs_path = found_header_path , found_via = "conda" )
90+ return LocatedHeaderDir (abs_path = found_header_path , found_via = "conda" )
9191 return None
9292
9393
94- def _find_ctk_header_directory (libname : str ) -> FoundHeaderDir | None :
94+ def _find_ctk_header_directory (libname : str ) -> LocatedHeaderDir | None :
9595 h_basename = supported_nvidia_headers .SUPPORTED_HEADERS_CTK [libname ]
9696 candidate_dirs = supported_nvidia_headers .SUPPORTED_SITE_PACKAGE_HEADER_DIRS_CTK [libname ]
9797
9898 for cdir in candidate_dirs :
99- if hdr_dir := _find_under_site_packages (cdir , h_basename ):
99+ if hdr_dir := _locate_under_site_packages (cdir , h_basename ):
100100 return hdr_dir
101101
102102 if hdr_dir := _find_based_on_conda_layout (libname , h_basename , True ):
103103 return hdr_dir
104104
105105 cuda_home = get_cuda_home_or_path ()
106106 if cuda_home : # noqa: SIM102
107- if result := _find_based_on_ctk_layout (libname , h_basename , cuda_home ):
108- return FoundHeaderDir (abs_path = result , found_via = "CUDA_HOME" )
107+ if result := _locate_based_on_ctk_layout (libname , h_basename , cuda_home ):
108+ return LocatedHeaderDir (abs_path = result , found_via = "CUDA_HOME" )
109109
110110 return None
111111
112112
113113@functools .cache
114- def locate_nvidia_header_directory (libname : str ) -> FoundHeaderDir | None :
114+ def locate_nvidia_header_directory (libname : str ) -> LocatedHeaderDir | None :
115115 """Locate the header directory for a supported NVIDIA library.
116116
117117 Args:
118118 libname (str): The short name of the library whose headers are needed
119119 (e.g., ``"nvrtc"``, ``"cusolver"``, ``"nvshmem"``).
120120
121121 Returns:
122- FoundHeaderDir or None: A FoundHeaderDir object containing the absolute path
122+ LocatedHeaderDir or None: A LocatedHeaderDir object containing the absolute path
123123 to the discovered header directory and information about where it was found,
124124 or ``None`` if the headers cannot be found.
125125
@@ -152,7 +152,7 @@ def locate_nvidia_header_directory(libname: str) -> FoundHeaderDir | None:
152152 candidate_dirs = supported_nvidia_headers .SUPPORTED_SITE_PACKAGE_HEADER_DIRS_NON_CTK .get (libname , [])
153153
154154 for cdir in candidate_dirs :
155- if found_hdr := _find_under_site_packages (cdir , h_basename ):
155+ if found_hdr := _locate_under_site_packages (cdir , h_basename ):
156156 return found_hdr
157157
158158 if found_hdr := _find_based_on_conda_layout (libname , h_basename , False ):
@@ -164,7 +164,7 @@ def locate_nvidia_header_directory(libname: str) -> FoundHeaderDir | None:
164164 for hdr_dir in sorted (glob .glob (cdir ), reverse = True ):
165165 if _joined_isfile (hdr_dir , h_basename ):
166166 # For system installs, we don't have a clear found_via, so use "system"
167- return FoundHeaderDir (abs_path = hdr_dir , found_via = "supported_install_dir" )
167+ return LocatedHeaderDir (abs_path = hdr_dir , found_via = "supported_install_dir" )
168168 return None
169169
170170
0 commit comments