1- import sys
2- import re
1+ import ctypes
32import os
4- from collections import namedtuple
53import platform
4+ import re
65import site
6+ import sys
7+ from collections import namedtuple
78from pathlib import Path
9+
10+ from numba import config
811from numba .core .config import IS_WIN32
912from numba .misc .findlib import find_lib
10- from numba import config
11- import ctypes
1213
1314_env_path_tuple = namedtuple ("_env_path_tuple" , ["by" , "info" ])
1415
@@ -41,9 +42,7 @@ def _find_first_valid_lazy(options):
4142def _build_options (pairs ):
4243 """Sorts and returns a list of (label, value) tuples according to SEARCH_PRIORITY."""
4344 priority_index = {label : i for i , label in enumerate (SEARCH_PRIORITY )}
44- return sorted (
45- pairs , key = lambda pair : priority_index .get (pair [0 ], float ("inf" ))
46- )
45+ return sorted (pairs , key = lambda pair : priority_index .get (pair [0 ], float ("inf" )))
4746
4847
4948def _find_valid_path (options ):
@@ -161,9 +160,7 @@ def get_nvrtc_dso_path():
161160
162161 return os .path .join (
163162 lib_dir ,
164- f"nvrtc64_{ cu_ver } _0.dll"
165- if IS_WIN32
166- else f"libnvrtc.so.{ cu_ver } " ,
163+ f"nvrtc64_{ cu_ver } _0.dll" if IS_WIN32 else f"libnvrtc.so.{ cu_ver } " ,
167164 )
168165 except RuntimeError :
169166 continue
@@ -186,16 +183,10 @@ def _get_nvrtc_wheel():
186183 dso_dir = os .path .dirname (nvrtc_path )
187184 builtins_path = os .path .join (
188185 dso_dir ,
189- [
190- f
191- for f in os .listdir (dso_dir )
192- if re .match ("^nvrtc-builtins.*.dll$" , f )
193- ][0 ],
186+ [f for f in os .listdir (dso_dir ) if re .match ("^nvrtc-builtins.*.dll$" , f )][0 ],
194187 )
195188 if not os .path .exists (builtins_path ):
196- raise RuntimeError (
197- f'Path does not exist: "{ builtins_path } "'
198- )
189+ raise RuntimeError (f'Path does not exist: "{ builtins_path } "' )
199190 return Path (dso_path )
200191
201192
@@ -348,7 +339,7 @@ def get_nvidia_static_cudalib_ctk():
348339 if not nvvm_ctk :
349340 return
350341
351- if IS_WIN32 and ("Library" not in nvvm_ctk ):
342+ if IS_WIN32 and ("Library" not in nvvm_ctk ): # noqa: SIM108
352343 # Location specific to CUDA 11.x packages on Windows
353344 dirs = ("Lib" , "x64" )
354345 else :
@@ -492,9 +483,7 @@ def get_conda_include_dir():
492483 if platform .system () == "Windows" :
493484 include_dir = os .path .join (sys .prefix , "Library" , "include" )
494485 elif target_name := get_current_cuda_target_name ():
495- include_dir = os .path .join (
496- sys .prefix , "targets" , target_name , "include"
497- )
486+ include_dir = os .path .join (sys .prefix , "targets" , target_name , "include" )
498487 else :
499488 # A fallback when target cannot determined
500489 # though usually it shouldn't.
@@ -503,9 +492,7 @@ def get_conda_include_dir():
503492 if (
504493 os .path .exists (include_dir )
505494 and os .path .isdir (include_dir )
506- and os .path .exists (
507- os .path .join (include_dir , "cuda_device_runtime_api.h" )
508- )
495+ and os .path .exists (os .path .join (include_dir , "cuda_device_runtime_api.h" ))
509496 ):
510497 return include_dir
511498 return
0 commit comments