Skip to content

Comments

[12.9.x backport] Refactor cuda-bindings setup.py to defer CUDA_HOME check to build time#1666

Merged
kkraus14 merged 1 commit intoNVIDIA:12.9.xfrom
kkraus14:backport-1652-to-12.9.x
Feb 20, 2026
Merged

[12.9.x backport] Refactor cuda-bindings setup.py to defer CUDA_HOME check to build time#1666
kkraus14 merged 1 commit intoNVIDIA:12.9.xfrom
kkraus14:backport-1652-to-12.9.x

Conversation

@kkraus14
Copy link
Collaborator

Summary

Backport of #1652 to the 12.9.x branch.

  • Introduces cuda_bindings/build_hooks.py as a custom PEP 517 build backend
  • Rewrites cuda_bindings/setup.py as a thin shim (preserving 12.9.x-specific redirector code)
  • Changes pyproject.toml build-backend from setuptools.build_meta to build_hooks

Conflict resolution: kept build_py_with_redirector, TopLevelFinderWithRedirector, editable_wheel_with_redirector, and the deprecated cuda/*.pyx source entry that are still present on 12.9.x.

Test plan

  • CI wheel builds pass on Linux and Windows

Closes #1635 (for 12.9.x)

Made with Cursor

NVIDIA#1652)

* Refactor cuda-bindings setup.py to defer CUDA_HOME check to build time

Move all CUDA-dependent logic (header parsing, code generation,
cythonization) from setup.py into a custom PEP 517 build backend
(build_hooks.py). Metadata queries (uv lock, uv sync, pip install
--dry-run) no longer require CUDA_HOME or CUDA_PATH to be set.

This follows the same pattern already used by cuda_core/build_hooks.py:
- Metadata hooks delegate directly to setuptools
- build_wheel/build_editable defer to _build_cuda_bindings()
- setup.py becomes a thin shim for ext_modules + parallel build_ext

Closes NVIDIA#1635

Co-authored-by: Cursor <cursoragent@cursor.com>

* Address review feedback and restore PARALLEL_LEVEL compat

- Move extra_link_args (strip) handling alongside extra_compile_args
  in the non-debug build path instead of a separate post-loop
- Rename compiler_directives to cython_directives for clarity
- Restore deprecated PARALLEL_LEVEL env var support in setup.py
  for build_ext parallelism parity with the old code

Co-authored-by: Cursor <cursoragent@cursor.com>

* Move clang detection to build_extensions for single check

Check the compiler once in build_extensions (plural) and fix up all
extensions in one pass, instead of checking per-extension in
build_extension (singular).

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 20, 2026

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@kkraus14
Copy link
Collaborator Author

/ok to test

@kkraus14 kkraus14 merged commit 20c54cc into NVIDIA:12.9.x Feb 20, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants