Skip to content

Commit 897b07b

Browse files
committed
Merge branch 'main' into cuda_core_build_hooks_get_cuda_version_macro
2 parents 78fb9d0 + 4754292 commit 897b07b

40 files changed

+1735
-826
lines changed

.github/actions/fetch_ctk/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ runs:
140140
ls -l $CUDA_PATH
141141
142142
- name: Upload CTK cache
143-
if: ${{ always() &&
143+
if: ${{ !cancelled() &&
144144
steps.ctk-get-cache.outputs.cache-hit != 'true' }}
145145
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
146146
with:

.github/workflows/build-wheel.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ jobs:
230230
with:
231231
# workaround for actions/runner-images#12377 (the cached 3.13.4 is buggy on Windows)
232232
python-version: ${{ matrix.python-version == '3.13' && '3.13.5' || matrix.python-version }}
233-
# allow prereleases only fetches prereleases for unreleased versions of Python
234-
allow-prereleases: true
235233

236234
- name: verify free-threaded build
237235
if: endsWith(matrix.python-version, 't')

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ jobs:
193193

194194
checks:
195195
name: Check job status
196+
if: always()
196197
runs-on: ubuntu-latest
197198
needs:
198199
- test-linux-64

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ jobs:
228228
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
229229
with:
230230
python-version: ${{ matrix.PY_VER }}
231-
allow-prereleases: true
232231
env:
233232
# we use self-hosted runners on which setup-python behaves weirdly...
234233
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ jobs:
213213
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
214214
with:
215215
python-version: ${{ matrix.PY_VER }}
216-
allow-prereleases: true
217216

218217
- name: Set up mini CTK
219218
if: ${{ matrix.LOCAL_CTK == '1' }}

cuda_bindings/docs/nv-versions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"version": "latest",
44
"url": "https://nvidia.github.io/cuda-python/cuda-bindings/latest/"
55
},
6+
{
7+
"version": "13.0.2",
8+
"url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.0.2/"
9+
},
610
{
711
"version": "13.0.1",
812
"url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.0.1/"

cuda_bindings/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def do_cythonize(extensions):
329329
return cythonize(
330330
extensions,
331331
nthreads=nthreads,
332-
compiler_directives=dict(language_level=3, embedsignature=True, binding=True),
332+
compiler_directives=dict(language_level=3, embedsignature=True, binding=True, freethreading_compatible=True),
333333
**extra_cythonize_kwargs,
334334
)
335335

cuda_bindings/tests/cython/build_tests.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ REM SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
55

66
setlocal
77
set CL=%CL% /I"%CUDA_HOME%\include"
8-
cythonize -3 -i %~dp0test_*.pyx
8+
cythonize -3 -i -Xfreethreading_compatible=True %~dp0test_*.pyx
99
endlocal

cuda_bindings/tests/cython/build_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ else
1414
exit 1
1515
fi
1616

17-
cythonize -3 -i ${SCRIPTPATH}/test_*.pyx
17+
cythonize -3 -i -Xfreethreading_compatible=True ${SCRIPTPATH}/test_*.pyx

cuda_core/build_hooks.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# - https://peps.python.org/pep-0517/
77
# - https://setuptools.pypa.io/en/latest/build_meta.html#dynamic-build-dependencies-and-other-build-meta-tweaks
88
# Specifically, there are 5 APIs required to create a proper build backend, see below.
9-
#
10-
# TODO: also implement PEP-660 API hooks
119

1210
import ctypes
1311
import functools
@@ -21,6 +19,7 @@
2119
from setuptools import Extension
2220
from setuptools import build_meta as _build_meta
2321

22+
prepare_metadata_for_build_editable = _build_meta.prepare_metadata_for_build_editable
2423
prepare_metadata_for_build_wheel = _build_meta.prepare_metadata_for_build_wheel
2524
build_sdist = _build_meta.build_sdist
2625
get_requires_for_build_sdist = _build_meta.get_requires_for_build_sdist
@@ -165,10 +164,13 @@ def _get_proper_cuda_bindings_major_version() -> str:
165164
_extensions = None
166165

167166

168-
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
169-
# Customizing this hook is needed because we must defer cythonization until cuda-bindings,
167+
def _build_cuda_core():
168+
# Customizing the build hooks is needed because we must defer cythonization until cuda-bindings,
170169
# now a required build-time dependency that's dynamically installed via the other hook below,
171170
# is installed. Otherwise, cimport any cuda.bindings modules would fail!
171+
#
172+
# This function populates "_extensions".
173+
global _extensions
172174

173175
# It seems setuptools' wildcard support has problems for namespace packages,
174176
# so we explicitly spell out all Extension instances.
@@ -193,21 +195,36 @@ def strip_prefix_suffix(filename):
193195

194196
nthreads = int(os.environ.get("CUDA_PYTHON_PARALLEL_LEVEL", os.cpu_count() // 2))
195197
compile_time_env = {"CUDA_CORE_BUILD_MAJOR": _get_proper_cuda_bindings_major_version()}
196-
197-
global _extensions
198198
_extensions = cythonize(
199199
ext_modules,
200200
verbose=True,
201201
language_level=3,
202202
nthreads=nthreads,
203-
compiler_directives={"embedsignature": True, "warn.deprecated.IF": False},
203+
compiler_directives={"embedsignature": True, "warn.deprecated.IF": False, "freethreading_compatible": True},
204204
compile_time_env=compile_time_env,
205205
)
206206

207+
return
208+
209+
210+
def build_editable(wheel_directory, config_settings=None, metadata_directory=None):
211+
_build_cuda_core()
212+
return _build_meta.build_editable(wheel_directory, config_settings, metadata_directory)
213+
214+
215+
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
216+
_build_cuda_core()
207217
return _build_meta.build_wheel(wheel_directory, config_settings, metadata_directory)
208218

209219

210-
def get_requires_for_build_wheel(config_settings=None):
220+
def _get_cuda_bindings_require():
211221
cuda_major = _get_proper_cuda_bindings_major_version()
212-
cuda_bindings_require = [f"cuda-bindings=={cuda_major}.*"]
213-
return _build_meta.get_requires_for_build_wheel(config_settings) + cuda_bindings_require
222+
return [f"cuda-bindings=={cuda_major}.*"]
223+
224+
225+
def get_requires_for_build_editable(config_settings=None):
226+
return _build_meta.get_requires_for_build_editable(config_settings) + _get_cuda_bindings_require()
227+
228+
229+
def get_requires_for_build_wheel(config_settings=None):
230+
return _build_meta.get_requires_for_build_wheel(config_settings) + _get_cuda_bindings_require()

0 commit comments

Comments
 (0)