Skip to content

Commit e19c17f

Browse files
authored
fix(python): Fix detection of cuda library on hosted runner (#554)
Closes #551.
1 parent fa8c3da commit e19c17f

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

.github/workflows/build-and-test-device.yaml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ on:
2828
- 'CMakeLists.txt'
2929
- '.github/workflows/build-and-test-device.yaml'
3030
- 'src/nanoarrow/**'
31+
- 'python/setup.py'
3132

3233
permissions:
3334
contents: read
@@ -132,18 +133,30 @@ jobs:
132133
cd build
133134
ctest -T memcheck .
134135
135-
- name: Check Python bindings with CUDA
136+
- name: Upload memcheck results
137+
if: failure() && matrix.config.label == 'default-build'
138+
uses: actions/upload-artifact@main
139+
with:
140+
name: nanoarrow-device-memcheck
141+
path: build/Testing/Temporary/MemoryChecker.*.log
142+
143+
- name: Set up Python
144+
if: matrix.config.label == 'with-cuda'
145+
uses: actions/setup-python@v5
146+
with:
147+
python-version: "3.12"
148+
cache: 'pip'
149+
150+
- name: Build Python bindings with CUDA
136151
if: matrix.config.label == 'with-cuda'
137152
env:
138153
NANOARROW_PYTHON_CUDA_HOME: "/usr/local/cuda"
139154
run: |
140155
cd python
141156
python3 -m pip install ".[test]" -vv
142-
python3 -m pytest -vv
143157
144-
- name: Upload memcheck results
145-
if: failure() && matrix.config.label == 'default-build'
146-
uses: actions/upload-artifact@main
147-
with:
148-
name: nanoarrow-device-memcheck
149-
path: build/Testing/Temporary/MemoryChecker.*.log
158+
- name: Test Python bindings with CUDA
159+
if: matrix.config.label == 'with-cuda'
160+
run: |
161+
cd python
162+
python3 -m pytest -vv

python/setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ def get_version(pkg_path):
8383
if not include_dir.is_dir():
8484
raise ValueError(f"CUDA include directory does not exist: '{include_dir}'")
8585

86-
lib_dirs = [d for d in possible_libs if d.exists()]
87-
if not lib_dirs:
88-
lib_dirs_err = ", ".join(f"'{d}" for d in possible_libs)
89-
raise ValueError(f"Can't find CUDA library directory. Checked {lib_dirs_err}")
90-
9186
device_include_dirs.append(str(include_dir))
92-
device_library_dirs.append(str(lib_dirs[0].parent))
9387
device_libraries.append("cuda")
9488
device_define_macros.append(("NANOARROW_DEVICE_WITH_CUDA", 1))
9589

90+
# Library might be already in a system library directory such that no -L flag
91+
# is needed
92+
lib_dirs = [d for d in possible_libs if d.exists()]
93+
if lib_dirs:
94+
device_library_dirs.append(str(lib_dirs[0].parent))
95+
9696

9797
def nanoarrow_extension(
9898
name, *, nanoarrow_c=False, nanoarrow_device=False, nanoarrow_ipc=False

0 commit comments

Comments
 (0)