Skip to content

Commit 2b74022

Browse files
committed
Define IS_WINDOWS = sys.platform == "win32" in supported_libs.py
1 parent 2cf3fa2 commit 2b74022

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

cuda_bindings/cuda/bindings/_path_finder/find_nvidia_dynamic_library.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import functools
55
import glob
66
import os
7-
import sys
87

98
from 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

1312
def _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

120119
def _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(

cuda_bindings/cuda/bindings/_path_finder/load_nvidia_dynamic_library.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import functools
55
import json
6-
import sys
76

87
from cuda.bindings._path_finder.find_nvidia_dynamic_library import _find_nvidia_dynamic_library
98
from cuda.bindings._path_finder.load_dl_common import (
@@ -12,8 +11,9 @@
1211
load_dependencies,
1312
load_in_subprocess,
1413
)
14+
from cuda.bindings._path_finder.supported_libs import IS_WINDOWS
1515

16-
if sys.platform == "win32":
16+
if IS_WINDOWS:
1717
from cuda.bindings._path_finder.load_dl_windows import (
1818
check_if_already_loaded_from_elsewhere,
1919
load_with_abs_path,

cuda_bindings/cuda/bindings/_path_finder/supported_libs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import sys
77

8+
IS_WINDOWS = sys.platform == "win32"
9+
810
SUPPORTED_LIBNAMES = (
911
# Core CUDA Runtime and Compiler
1012
"nvJitLink",
@@ -65,7 +67,7 @@
6567
+ PARTIALLY_SUPPORTED_LIBNAMES_WINDOWS_ONLY
6668
)
6769

68-
if sys.platform == "win32":
70+
if IS_WINDOWS:
6971
PARTIALLY_SUPPORTED_LIBNAMES = PARTIALLY_SUPPORTED_LIBNAMES_WINDOWS
7072
else:
7173
PARTIALLY_SUPPORTED_LIBNAMES = PARTIALLY_SUPPORTED_LIBNAMES_LINUX

0 commit comments

Comments
 (0)