Skip to content

Commit e56b97a

Browse files
authored
Merge pull request #359 from leofang/cython_11_8
[Backport] Enable Cython tests for `cuda.bindings`
2 parents 1f01b00 + d32a05c commit e56b97a

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

.github/actions/fetch_ctk/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@ runs:
146146
run: |
147147
CUDA_PATH=$(realpath "./cuda_toolkit")
148148
echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV
149+
echo "CUDA_HOME=${CUDA_PATH}" >> $GITHUB_ENV
149150
echo "${CUDA_PATH}/bin" >> $GITHUB_PATH
150151
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${CUDA_PATH}/lib" >> $GITHUB_ENV

.github/workflows/build-and-test.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ jobs:
234234
uses: actions/setup-python@v5
235235
with:
236236
python-version: ${{ matrix.python-version }}
237+
env:
238+
# we use self-hosted runners on which setup-python behaves weirdly...
239+
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"
237240

238241
- name: Set up mini CTK
239242
uses: ./.github/actions/fetch_ctk
@@ -255,6 +258,13 @@ jobs:
255258
pushd ./cuda_bindings
256259
pip install -r requirements.txt
257260
pytest -rxXs tests/
258-
# TODO: enable cython tests
259-
#pytest tests/cython
261+
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
262+
# cython tests require gcc
263+
apt install -y build-essential
264+
bash tests_cython/build_tests.sh
265+
elif [[ "${{ matrix.host-platform }}" == win* ]]; then
266+
# TODO: enable this once win-64 runners are up
267+
exit 1
268+
fi
269+
pytest -rxXs tests_cython
260270
popd
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname "$0")"
4+
CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH cythonize -3 -i test_*.pyx

cuda_bindings/tests_cython/test_ccuda.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8+
9+
# distutils: language=c++
10+
811
from libc.string cimport (
912
memset,
1013
memcmp
@@ -53,4 +56,4 @@ def test_ccuda_memcpy():
5356
err = ccuda.cuMemFree(dptr)
5457
assert(err == 0)
5558
err = ccuda.cuCtxDestroy(ctx)
56-
assert(err == 0)
59+
assert(err == 0)

cuda_bindings/tests_cython/test_ccudart.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8+
9+
# distutils: language=c++
10+
811
from libc.string cimport (
912
memset,
1013
memcmp

cuda_bindings/tests_cython/test_interoperability_cython.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8+
9+
# distutils: language=c++
10+
811
import pytest
912
import cuda.cuda as cuda
1013
import cuda.cudart as cudart

0 commit comments

Comments
 (0)