Refactor cuda-bindings setup.py to defer CUDA_HOME check to build time#1652
Refactor cuda-bindings setup.py to defer CUDA_HOME check to build time#1652kkraus14 wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
|
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. |
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
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>
30954a9 to
dc8be9b
Compare
|
/ok to test |
|
mdboom
left a comment
There was a problem hiding this comment.
A few minor comments, none critical.
cuda_bindings/build_hooks.py
Outdated
|
|
||
| if strip and sys.platform == "linux" and "--debug" not in sys.argv: | ||
| for ext in extensions: | ||
| ext.extra_link_args.append("-Wl,--strip-all") |
There was a problem hiding this comment.
It would probably be less confusing to handle extra_link_args in parallel with extra_compile_args, (there is already a "non debug build" path above) rather than handling it separately here.
cuda_bindings/build_hooks.py
Outdated
| ext.extra_link_args.append("-Wl,--strip-all") | ||
|
|
||
| # Cythonize | ||
| compiler_directives = dict(language_level=3, embedsignature=True, binding=True, freethreading_compatible=True) |
There was a problem hiding this comment.
This name was less confusing in its old location. But now since it's in a function doing a lot more things, maybe change it to cython_directives?
- 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>
|
/ok to test |
Summary
cuda_bindings/build_hooks.pyas a custom PEP 517 build backend that defers all CUDA-dependent logic (header parsing, code generation, cythonization) tobuild_wheel/build_editablecuda_bindings/setup.pyas a thin shim (matchingcuda_core/setup.py) that only provides theext_modulesbridge and parallelbuild_extpyproject.tomlbuild-backend fromsetuptools.build_metatobuild_hooksMetadata queries (
uv lock,uv sync,pip install --dry-run) no longer requireCUDA_HOMEorCUDA_PATHto be set.Follows the same pattern already used by
cuda_core/build_hooks.py.Test plan
python -c "import build_hooks"succeeds withoutCUDA_HOME(confirmed locally)uv lock/uv pip compileworks withoutCUDA_HOMECUDA_HOME=/usr/local/cuda uv build --wheelproduces a working wheelpip install -e .withCUDA_HOMEset works for editable installsCloses #1635
Made with Cursor