Skip to content

Commit 5711602

Browse files
committed
Remove fallback code paths in _find_so_using_nvidia_lib_dirs, _find_dll_using_nvidia_bin_dirs and associated foreign_wheels unit test
1 parent 1c0a0e5 commit 5711602

File tree

7 files changed

+6
-66
lines changed

7 files changed

+6
-66
lines changed

.github/workflows/test-wheel-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ jobs:
325325
run: |
326326
set -euo pipefail
327327
pushd cuda_pathfinder
328-
pip install --only-binary=:all: -v ".[nvidia_wheels_cu${TEST_CUDA_MAJOR},nvidia_wheels_host,foreign_wheels]"
328+
pip install --only-binary=:all: -v ".[nvidia_wheels_cu${TEST_CUDA_MAJOR},nvidia_wheels_host]"
329329
pip list
330330
popd
331331

.github/workflows/test-wheel-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ jobs:
292292
shell: bash --noprofile --norc -xeuo pipefail {0}
293293
run: |
294294
pushd cuda_pathfinder
295-
pip install --only-binary=:all: -v ".[nvidia_wheels_cu${TEST_CUDA_MAJOR},nvidia_wheels_host,foreign_wheels]"
295+
pip install --only-binary=:all: -v ".[nvidia_wheels_cu${TEST_CUDA_MAJOR},nvidia_wheels_host]"
296296
pip list
297297
popd
298298

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/find_nvidia_dynamic_lib.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
SITE_PACKAGES_LIBDIRS_WINDOWS,
1515
is_suppressed_dll_file,
1616
)
17-
from cuda.pathfinder._utils.find_site_packages_dll import find_all_dll_files_via_metadata
18-
from cuda.pathfinder._utils.find_site_packages_so import find_all_so_files_via_metadata
1917
from cuda.pathfinder._utils.find_sub_dirs import find_sub_dirs, find_sub_dirs_all_sitepackages
2018

2119

@@ -34,7 +32,6 @@ def _find_so_using_nvidia_lib_dirs(
3432
) -> Optional[str]:
3533
rel_dirs = SITE_PACKAGES_LIBDIRS_LINUX.get(libname)
3634
if rel_dirs is not None:
37-
# Fast direct access with minimal globbing.
3835
sub_dirs_searched = []
3936
file_wild = so_basename + "*"
4037
for rel_dir in rel_dirs:
@@ -52,14 +49,6 @@ def _find_so_using_nvidia_lib_dirs(
5249
sub_dirs_searched.append(sub_dir)
5350
for sub_dir in sub_dirs_searched:
5451
_no_such_file_in_sub_dirs(sub_dir, file_wild, error_messages, attachments)
55-
else:
56-
# This fallback is relatively slow, but acceptable.
57-
candidates = find_all_so_files_via_metadata().get(so_basename)
58-
if candidates:
59-
so_versions = candidates.keys()
60-
# For now, simply take the first candidate after sorting.
61-
all_abs_paths: list[str] = candidates[next(iter(sorted(so_versions)))]
62-
return next(iter(sorted(all_abs_paths)))
6352
return None
6453

6554

@@ -77,7 +66,6 @@ def _find_dll_using_nvidia_bin_dirs(
7766
) -> Optional[str]:
7867
rel_dirs = SITE_PACKAGES_LIBDIRS_WINDOWS.get(libname)
7968
if rel_dirs is not None:
80-
# Fast direct access with minimal globbing.
8169
sub_dirs_searched = []
8270
for rel_dir in rel_dirs:
8371
sub_dir = tuple(rel_dir.split(os.path.sep))
@@ -88,20 +76,6 @@ def _find_dll_using_nvidia_bin_dirs(
8876
sub_dirs_searched.append(sub_dir)
8977
for sub_dir in sub_dirs_searched:
9078
_no_such_file_in_sub_dirs(sub_dir, lib_searched_for, error_messages, attachments)
91-
else:
92-
# This fallback is relatively slow, but acceptable.
93-
libname_lower = libname.lower()
94-
candidates = []
95-
for relname, abs_paths in find_all_dll_files_via_metadata().items():
96-
if is_suppressed_dll_file(relname):
97-
continue
98-
if relname.startswith(libname_lower):
99-
for abs_path in abs_paths:
100-
candidates.append(abs_path)
101-
if candidates:
102-
candidates.sort()
103-
result: str = candidates[0] # help mypy
104-
return result
10579
return None
10680

10781

cuda_pathfinder/pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ nvidia_wheels_cu13 = [
2929
nvidia_wheels_host = [
3030
"nvpl-fft; platform_system == 'Linux' and platform_machine == 'aarch64'",
3131
]
32-
foreign_wheels = [
33-
# For tests/test_load_nvidia_dynamic_lib.py. See comment there (look for pygit2).
34-
"pygit2",
35-
]
3632

3733
[project.urls]
3834
Repository = "https://github.com/NVIDIA/cuda-python"

cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import functools
5-
import importlib.metadata
65
import os
76
from unittest.mock import patch
87

@@ -70,31 +69,6 @@ def test_runtime_error_on_non_64bit_python():
7069
load_nvidia_dynamic_lib("not_used")
7170

7271

73-
def _get_git2_libname():
74-
# For testing the fallback code paths in find_nvidia_dynamic_lib.py we need a
75-
# "foreign" shared library unrelated to CUDA. To keep things simple, we pick a
76-
# small, widely used wheel that bundles its own .so/.dll. The choice of pygit2
77-
# is arbitrary — it is a stable dependency and unrelated to NVIDIA software.
78-
try:
79-
pygit2_dist = importlib.metadata.distribution("pygit2")
80-
except importlib.metadata.PackageNotFoundError:
81-
pass
82-
else:
83-
for df in pygit2_dist.files:
84-
fname = df.name
85-
libname = ""
86-
if supported_nvidia_libs.IS_WINDOWS:
87-
if fname.endswith(".dll"):
88-
libname = os.path.basename(fname)[:-4]
89-
elif fname.startswith("libgit2"):
90-
idx = fname.find(".so")
91-
if idx > 0:
92-
libname = fname[3:idx]
93-
if libname.startswith("git2"):
94-
return libname
95-
return None
96-
97-
9872
@functools.cache
9973
def _get_libnames_for_test_load_nvidia_dynamic_lib():
10074
result = list(SUPPORTED_NVIDIA_LIBNAMES)
@@ -113,10 +87,6 @@ def _get_libnames_for_test_load_nvidia_dynamic_lib():
11387
if so_basename in all_dyn_libs:
11488
result.append(libname)
11589

116-
libname = _get_git2_libname()
117-
if libname is not None:
118-
result.append(libname)
119-
12090
return tuple(result)
12191

12292

toolshed/collect_site_packages_dll_files.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ function Fresh-Venv {
2323
Set-Location -Path 'cuda_pathfinder'
2424

2525
Fresh-Venv -Path '..\TmpCp12Venv'
26-
pip install --only-binary=:all: -e '.[test,nvidia_wheels_cu12,nvidia_wheels_host,foreign_wheels]'
26+
pip install --only-binary=:all: -e '.[test,nvidia_wheels_cu12,nvidia_wheels_host]'
2727
deactivate
2828

2929
Fresh-Venv -Path '..\TmpCp13Venv'
30-
pip install --only-binary=:all: -e '.[test,nvidia_wheels_cu13,nvidia_wheels_host,foreign_wheels]'
30+
pip install --only-binary=:all: -e '.[test,nvidia_wheels_cu13,nvidia_wheels_host]'
3131
deactivate
3232

3333
Set-Location -Path '..'

toolshed/collect_site_packages_so_files.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ fresh_venv() {
1717
cd cuda_pathfinder/
1818
fresh_venv ../TmpCp12Venv
1919
set -x
20-
pip install --only-binary=:all: -e .[test,nvidia_wheels_cu12,nvidia_wheels_host,foreign_wheels]
20+
pip install --only-binary=:all: -e .[test,nvidia_wheels_cu12,nvidia_wheels_host]
2121
set +x
2222
deactivate
2323
fresh_venv ../TmpCp13Venv
2424
set -x
25-
pip install --only-binary=:all: -e .[test,nvidia_wheels_cu13,nvidia_wheels_host,foreign_wheels]
25+
pip install --only-binary=:all: -e .[test,nvidia_wheels_cu13,nvidia_wheels_host]
2626
set +x
2727
deactivate
2828
cd ..

0 commit comments

Comments
 (0)