Skip to content

Commit a4a6721

Browse files
committed
add cuda-python pure Python wheel
1 parent 66739e1 commit a4a6721

File tree

6 files changed

+116
-10
lines changed

6 files changed

+116
-10
lines changed

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

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
# (matrix.host-platform == 'win-64' && 'windows-amd64-cpu8') }}
4343
outputs:
4444
BUILD_CTK_VER: ${{ steps.pass_env.outputs.CUDA_VERSION }}
45+
defaults:
46+
run:
47+
shell: bash --noprofile --norc -xeuo pipefail {0}
4548
steps:
4649
- name: Checkout ${{ github.event.repository.name }}
4750
uses: actions/checkout@v4
@@ -63,7 +66,6 @@ jobs:
6366
uses: ilammy/msvc-dev-cmd@v1
6467

6568
- name: Set environment variables
66-
shell: bash --noprofile --norc -xeuo pipefail {0}
6769
run: |
6870
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
6971
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
@@ -81,7 +83,6 @@ jobs:
8183
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
8284

8385
- name: Dump environment
84-
shell: bash --noprofile --norc -xeuo pipefail {0}
8586
run: |
8687
env
8788
@@ -110,7 +111,6 @@ jobs:
110111
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
111112

112113
- name: List the cuda.bindings artifacts directory
113-
shell: bash --noprofile --norc -xeuo pipefail {0}
114114
run: |
115115
if [[ "${{ matrix.host-platform }}" == win* ]]; then
116116
export CHOWN=chown
@@ -122,8 +122,8 @@ jobs:
122122
123123
# TODO: enable this after NVIDIA/cuda-python#297 is resolved
124124
# - name: Check cuda.bindings wheel
125-
# shell: bash --noprofile --norc -xeuo pipefail {0}
126125
# run: |
126+
# pip install twine
127127
# twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
128128

129129
- name: Upload cuda.bindings build artifacts
@@ -132,7 +132,36 @@ jobs:
132132
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
133133
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
134134
if-no-files-found: error
135-
overwrite: 'true'
135+
136+
# upload-artifact's "overwrite: true" option has a race condition among parallel
137+
# jobs, so we let job 0 do the work
138+
- name: Build and check cuda-python wheel
139+
if: ${{ strategy.job-index == 0 }}
140+
run: |
141+
pushd cuda_python
142+
pip wheel -v --no-deps .
143+
pip install twine # TODO: remove me (see above)
144+
twine check *.whl
145+
popd
146+
147+
- name: List the cuda-python artifacts directory
148+
if: ${{ strategy.job-index == 0 }}
149+
run: |
150+
if [[ "${{ matrix.host-platform }}" == win* ]]; then
151+
export CHOWN=chown
152+
else
153+
export CHOWN="sudo chown"
154+
fi
155+
$CHOWN -R $(whoami) cuda_python/*.whl
156+
ls -lahR cuda_python
157+
158+
- name: Upload cuda-python build artifacts
159+
if: ${{ strategy.job-index == 0 }}
160+
uses: actions/upload-artifact@v4
161+
with:
162+
name: cuda-python-wheel
163+
path: cuda_python/*.whl
164+
if-no-files-found: error
136165

137166
- name: Pass environment variables to the next runner
138167
id: pass_env
@@ -186,9 +215,11 @@ jobs:
186215
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
187216
needs:
188217
- build
218+
defaults:
219+
run:
220+
shell: bash --noprofile --norc -xeuo pipefail {0}
189221
steps:
190222
- name: Ensure GPU is working
191-
shell: bash --noprofile --norc -xeuo pipefail {0}
192223
run: nvidia-smi
193224

194225
- name: Checkout ${{ github.event.repository.name }}
@@ -198,7 +229,6 @@ jobs:
198229
ref: ${{ github.head_ref || github.ref_name }}
199230

200231
- name: Set environment variables
201-
shell: bash --noprofile --norc -xeuo pipefail {0}
202232
run: |
203233
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
204234
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
@@ -221,14 +251,24 @@ jobs:
221251
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
222252
echo "SKIP_CUDA_BINDINGS_TEST=${SKIP_CUDA_BINDINGS_TEST}" >> $GITHUB_ENV
223253
254+
- name: Download cuda-python build artifacts
255+
uses: actions/download-artifact@v4
256+
with:
257+
name: cuda-python-wheel
258+
path: .
259+
260+
- name: Display structure of downloaded cuda-python artifacts
261+
run: |
262+
pwd
263+
ls -lahR .
264+
224265
- name: Download cuda.bindings build artifacts
225266
uses: actions/download-artifact@v4
226267
with:
227268
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
228269
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
229270

230271
- name: Display structure of downloaded cuda.bindings artifacts
231-
shell: bash --noprofile --norc -xeuo pipefail {0}
232272
run: |
233273
pwd
234274
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
@@ -251,7 +291,6 @@ jobs:
251291

252292
- name: Run cuda.bindings tests
253293
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }}
254-
shell: bash --noprofile --norc -xeuo pipefail {0}
255294
run: |
256295
pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
257296
if [[ "${{ matrix.local-ctk }}" == 1 ]]; then
@@ -280,6 +319,10 @@ jobs:
280319
fi
281320
popd
282321
322+
- name: Ensure cuda-python installable
323+
run: |
324+
pip install cuda_python*.whl
325+
283326
checks:
284327
name: Check job status
285328
permissions:

cuda_bindings/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ requires = ["setuptools", "cython", "pyclibrary"]
1111
build-backend = "setuptools.build_meta"
1212

1313
[project]
14-
name = "cuda-python"
14+
name = "cuda-bindings"
1515
description = "Python bindings for CUDA"
1616
authors = [{name = "NVIDIA Corporation", email = "[email protected]"},]
1717
license = {file = "LICENSE"}

cuda_python/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE

cuda_python/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

cuda_python/pyproject.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2023-2025 NVIDIA Corporation. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4+
5+
[build-system]
6+
requires = ["setuptools",]
7+
build-backend = "setuptools.build_meta"
8+
9+
[project]
10+
name = "cuda-python"
11+
description = "CUDA Python: Performance meets Productivity"
12+
readme = {file = "README.md", content-type = "text/markdown"}
13+
authors = [{name = "NVIDIA Corporation", email = "[email protected]"},]
14+
license = {file = "LICENSE"}
15+
classifiers = [
16+
"Operating System :: POSIX :: Linux",
17+
"Operating System :: Microsoft :: Windows",
18+
"Topic :: Software Development :: Libraries",
19+
"Topic :: Education",
20+
"Topic :: Scientific/Engineering",
21+
"Intended Audience :: Developers",
22+
"Intended Audience :: Science/Research",
23+
"Intended Audience :: End Users/Desktop",
24+
"License :: Other/Proprietary License",
25+
"Programming Language :: Python :: 3 :: Only",
26+
"Programming Language :: Python :: 3.9",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
30+
"Programming Language :: Python :: 3.13",
31+
"Programming Language :: Python :: Implementation :: CPython",
32+
"Environment :: GPU :: NVIDIA CUDA",
33+
"Environment :: GPU :: NVIDIA CUDA :: 12",
34+
]
35+
dynamic = ["version", "dependencies"]
36+
37+
[project.urls]
38+
homepage = "https://nvidia.github.io/cuda-python/"
39+
documentation = "https://nvidia.github.io/cuda-python/"
40+
repository = "https://github.com/NVIDIA/cuda-python/"
41+
issues = "https://github.com/NVIDIA/cuda-python/issues/"

cuda_python/setup.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
2+
#
3+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4+
5+
from setuptools import setup
6+
7+
# We want to keep the version in sync with cuda.bindings, but setuptools would not let
8+
# us to refer to any files outside of the project root, so we have to employ our own
9+
# run-time lookup using setup()...
10+
with open("../cuda_bindings/cuda/bindings/_version.py") as f:
11+
exec(f.read())
12+
version = __version__ # noqa: F821
13+
del __version__ # noqa: F821
14+
15+
setup(
16+
version=version,
17+
install_requires=[
18+
f"cuda-bindings~={version}",
19+
],
20+
)

0 commit comments

Comments
 (0)