From 903b394cfc904b807ff36e8c1f2ff1261a578363 Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Sat, 25 Apr 2026 01:12:35 -0700 Subject: [PATCH 1/3] fix(test): unblock root pixi run test workflow `pixi run test` failed at the cuda_bindings build stage because list-form pixi `cmd` arrays didn't expand `$PIXI_ENVIRONMENT_NAME` reliably, so the inner per-package `pixi run` calls picked the cuda_bindings default environment (no cuda-version pin). The conda solver then resolved cuda-version=12.9 and the build failed with a missing `CUatomicOperation_enum` (a CUDA-13.x-only symbol). Wrap the three test-* tasks in `bash -c '...'` so the shell expands `$PIXI_ENVIRONMENT_NAME` and forward it explicitly via `-e` to each inner pixi run. Once the bindings build was unblocked, cuda_core's cython test build hit a second issue: `cythonize` cannot resolve `cimport cuda.bindings.*` against pixi-build's editable install, which exposes the cuda namespace package via a finder hook that Cython's filesystem .pxd resolver does not consult. Replace the `cythonize` CLI invocation with a small Python wrapper that calls `Cython.Build.cythonize()` with an explicit `include_path` resolved from the imported `cuda.bindings` package. Co-Authored-By: Claude Opus 4.7 (1M context) --- cuda_core/tests/cython/build_tests.py | 31 +++++++++++++++++++++++++++ cuda_core/tests/cython/build_tests.sh | 2 +- pixi.toml | 25 ++++++++++----------- 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 cuda_core/tests/cython/build_tests.py diff --git a/cuda_core/tests/cython/build_tests.py b/cuda_core/tests/cython/build_tests.py new file mode 100644 index 00000000000..4eea33291e6 --- /dev/null +++ b/cuda_core/tests/cython/build_tests.py @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# The Cython CLI has no --include-path flag, and pixi-build's editable install +# exposes the cuda namespace package through a finder hook that Cython's +# filesystem .pxd resolver does not consult. Locate the package's parent +# directory at runtime and pass it to cythonize() explicitly. + +import glob +import os +from pathlib import Path + +import cuda.bindings +from Cython.Build import cythonize +from setuptools import setup + +HERE = Path(__file__).resolve().parent +CUDA_PKG_PARENT = Path(cuda.bindings.__file__).parents[2] + +# `setup(... build_ext --inplace)` resolves the .so destination relative to cwd +# and the module's basename, so chdir into HERE before invoking it. +os.chdir(HERE) + +extensions = cythonize( + sorted(glob.glob("test_*.pyx")), + language_level=3, + include_path=[str(CUDA_PKG_PARENT)], + compiler_directives={"freethreading_compatible": True}, +) + +setup(ext_modules=extensions, script_args=["build_ext", "--inplace"]) diff --git a/cuda_core/tests/cython/build_tests.sh b/cuda_core/tests/cython/build_tests.sh index 3e20136133a..01e45b235d6 100755 --- a/cuda_core/tests/cython/build_tests.sh +++ b/cuda_core/tests/cython/build_tests.sh @@ -15,4 +15,4 @@ else exit 1 fi -cythonize -3 -i -Xfreethreading_compatible=True ${SCRIPTPATH}/test_*.pyx +python "${SCRIPTPATH}/build_tests.py" diff --git a/pixi.toml b/pixi.toml index 71d6b5d91bc..d36e8f22986 100644 --- a/pixi.toml +++ b/pixi.toml @@ -19,29 +19,30 @@ PIXI_ENVIRONMENT_NAME = "${PIXI_ENVIRONMENT_NAME/default/cu13}" # Test Tasks # Runs tests across all sub-packages: pathfinder → bindings → core (dependency order) -# Each sub-package has its own pixi.toml; the -e environment propagates via PIXI_ENVIRONMENT_NAME +# Each sub-package has its own pixi.toml; the active environment is forwarded +# explicitly via -e "$PIXI_ENVIRONMENT_NAME" in each inner pixi run. # # Usage: pixi run test | pixi run -e cu12 test | pixi run -e cu13 test [target.linux.tasks.test-pathfinder] cmd = [ - "pixi", - "run", - "--manifest-path", - "$PIXI_PROJECT_ROOT/cuda_pathfinder", - "test", + "bash", + "-c", + 'pixi run --manifest-path "$PIXI_PROJECT_ROOT/cuda_pathfinder" -e "$PIXI_ENVIRONMENT_NAME" test', ] [target.linux.tasks.test-bindings] cmd = [ - "pixi", - "run", - "--manifest-path", - "$PIXI_PROJECT_ROOT/cuda_bindings", - "test", + "bash", + "-c", + 'pixi run --manifest-path "$PIXI_PROJECT_ROOT/cuda_bindings" -e "$PIXI_ENVIRONMENT_NAME" test', ] [target.linux.tasks.test-core] -cmd = ["pixi", "run", "--manifest-path", "$PIXI_PROJECT_ROOT/cuda_core", "test"] +cmd = [ + "bash", + "-c", + 'pixi run --manifest-path "$PIXI_PROJECT_ROOT/cuda_core" -e "$PIXI_ENVIRONMENT_NAME" test', +] [target.linux.tasks.test] depends-on = [ From 241b3e6391eb623f363372eab43ef360f8ad3054 Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Sat, 25 Apr 2026 01:15:41 -0700 Subject: [PATCH 2/3] fix(test): satisfy ruff isort grouping in build_tests.py Co-Authored-By: Claude Opus 4.7 (1M context) --- cuda_core/tests/cython/build_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cuda_core/tests/cython/build_tests.py b/cuda_core/tests/cython/build_tests.py index 4eea33291e6..47f2c8eb6da 100644 --- a/cuda_core/tests/cython/build_tests.py +++ b/cuda_core/tests/cython/build_tests.py @@ -10,10 +10,11 @@ import os from pathlib import Path -import cuda.bindings from Cython.Build import cythonize from setuptools import setup +import cuda.bindings + HERE = Path(__file__).resolve().parent CUDA_PKG_PARENT = Path(cuda.bindings.__file__).parents[2] From d9668c6ed0856966965da2985ee8a8c8bc6e37e4 Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Sat, 25 Apr 2026 01:24:18 -0700 Subject: [PATCH 3/3] fix(test): replace cython build wrapper with PYTHONPATH shim Drop cuda_core/tests/cython/build_tests.py in favor of a small PYTHONPATH shim in build_tests.sh. Same outcome (Cython's .pxd resolver finds cuda.bindings via the package's parent directory), three lines instead of a separate setuptools entry point. Co-Authored-By: Claude Opus 4.7 (1M context) --- cuda_core/tests/cython/build_tests.py | 32 --------------------------- cuda_core/tests/cython/build_tests.sh | 9 +++++++- 2 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 cuda_core/tests/cython/build_tests.py diff --git a/cuda_core/tests/cython/build_tests.py b/cuda_core/tests/cython/build_tests.py deleted file mode 100644 index 47f2c8eb6da..00000000000 --- a/cuda_core/tests/cython/build_tests.py +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# The Cython CLI has no --include-path flag, and pixi-build's editable install -# exposes the cuda namespace package through a finder hook that Cython's -# filesystem .pxd resolver does not consult. Locate the package's parent -# directory at runtime and pass it to cythonize() explicitly. - -import glob -import os -from pathlib import Path - -from Cython.Build import cythonize -from setuptools import setup - -import cuda.bindings - -HERE = Path(__file__).resolve().parent -CUDA_PKG_PARENT = Path(cuda.bindings.__file__).parents[2] - -# `setup(... build_ext --inplace)` resolves the .so destination relative to cwd -# and the module's basename, so chdir into HERE before invoking it. -os.chdir(HERE) - -extensions = cythonize( - sorted(glob.glob("test_*.pyx")), - language_level=3, - include_path=[str(CUDA_PKG_PARENT)], - compiler_directives={"freethreading_compatible": True}, -) - -setup(ext_modules=extensions, script_args=["build_ext", "--inplace"]) diff --git a/cuda_core/tests/cython/build_tests.sh b/cuda_core/tests/cython/build_tests.sh index 01e45b235d6..c92f3dd04eb 100755 --- a/cuda_core/tests/cython/build_tests.sh +++ b/cuda_core/tests/cython/build_tests.sh @@ -15,4 +15,11 @@ else exit 1 fi -python "${SCRIPTPATH}/build_tests.py" +# pixi-build's editable install exposes the cuda namespace package via a +# finder hook that Cython's filesystem .pxd resolver does not consult. +# Surface the package's parent directory on PYTHONPATH so `cimport +# cuda.bindings.*` can locate the .pxd files. +CUDA_PKG_PARENT=$(python -c "import cuda.bindings as m, os; print(os.path.dirname(os.path.dirname(os.path.dirname(m.__file__))))") +export PYTHONPATH="${CUDA_PKG_PARENT}${PYTHONPATH:+:${PYTHONPATH}}" + +cythonize -3 -i -Xfreethreading_compatible=True ${SCRIPTPATH}/test_*.pyx