44import functools
55import glob
66import os
7- import sys
87
98from cuda .bindings ._path_finder .find_sub_dirs import find_sub_dirs_all_sitepackages
10- from cuda .bindings ._path_finder .supported_libs import is_suppressed_dll_file
9+ from cuda .bindings ._path_finder .supported_libs import IS_WINDOWS , is_suppressed_dll_file
1110
1211
1312def _no_such_file_in_sub_dirs (sub_dirs , file_wild , error_messages , attachments ):
@@ -71,7 +70,7 @@ def _find_lib_dir_using_cuda_home(libname):
7170 cuda_home = _get_cuda_home ()
7271 if cuda_home is None :
7372 return None
74- if sys . platform == "win32" :
73+ if IS_WINDOWS :
7574 if libname == "nvvm" : # noqa: SIM108
7675 subdirs = (os .path .join ("nvvm" , "bin" ),)
7776 else :
@@ -118,10 +117,7 @@ def _find_dll_using_lib_dir(lib_dir, libname, error_messages, attachments):
118117
119118
120119def _find_nvvm_lib_dir_from_other_abs_path (other_abs_path ):
121- if sys .platform == "win32" :
122- nvvm_subdir = "bin"
123- else :
124- nvvm_subdir = "lib64"
120+ nvvm_subdir = "bin" if IS_WINDOWS else "lib64"
125121 while other_abs_path :
126122 if os .path .isdir (other_abs_path ):
127123 nvvm_lib_dir = os .path .join (other_abs_path , "nvvm" , nvvm_subdir )
@@ -139,7 +135,7 @@ def __init__(self, libname: str):
139135 self .abs_path = None
140136
141137 cuda_home_lib_dir = _find_lib_dir_using_cuda_home (libname )
142- if sys . platform == "win32" :
138+ if IS_WINDOWS :
143139 self .lib_searched_for = f"{ libname } *.dll"
144140 if cuda_home_lib_dir is not None :
145141 self .abs_path = _find_dll_using_lib_dir (
@@ -165,7 +161,7 @@ def retry_with_other_abs_path(self, other_abs_path):
165161 nvvm_lib_dir = _find_nvvm_lib_dir_from_other_abs_path (other_abs_path )
166162 if nvvm_lib_dir is None :
167163 return
168- if sys . platform == "win32" :
164+ if IS_WINDOWS :
169165 self .abs_path = _find_dll_using_lib_dir (nvvm_lib_dir , self .libname , self .error_messages , self .attachments )
170166 else :
171167 self .abs_path = _find_so_using_lib_dir (
0 commit comments