Skip to content

Exclude Cython-generated .cpp files from wheels - #1578

Merged
Andy-Jost merged 1 commit into
NVIDIA:mainfrom
Andy-Jost:fix-cpp-in-wheel
Feb 5, 2026
Merged

Andy-Jost merged 1 commit into
NVIDIA:mainfrom
Andy-Jost:fix-cpp-in-wheel

Conversation

@Andy-Jost

@Andy-Jost Andy-Jost commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cython-generated .cpp files were being included in the wheels, consuming significant space without providing value to users (they have the compiled binaries already).

This PR:

  • Uses cythonize build_dir parameter to place generated .cpp files in build/cython/ instead of the source tree
  • Adds exclude-package-data for *.cpp in cuda-bindings to exclude any remaining .cpp files

Size Reduction

Installed Package Size (uncompressed)

Package Before After Reduction
cuda-bindings 141MB (24 .cpp files) 37MB (0 .cpp files) 74%
cuda-core 28MB (24 .cpp files) 5.4MB (0 .cpp files) 81%
Total 169MB 42.4MB 75%

Wheel Size (compressed)

Package Before After Reduction
cuda-bindings 16MB 7.3MB 54%
cuda-core 17MB 1.7MB 90%
Total 33MB 9MB 73%

Test Plan

  • CI passes
  • Verify wheels do not contain .cpp files
  • Verify packages install and function correctly

Use cythonize build_dir parameter to place generated .cpp files
in build/cython/ instead of the source tree. This prevents them
from being included in the wheel.

Additionally, add exclude-package-data for *.cpp in cuda-bindings
to exclude any remaining .cpp files from the package.
@copy-pr-bot

copy-pr-bot Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Andy-Jost

Copy link
Copy Markdown
Contributor Author

/ok to test 15cc9f5

@Andy-Jost
Andy-Jost requested review from leofang and mdboom and removed request for leofang February 5, 2026 18:51
@Andy-Jost Andy-Jost self-assigned this Feb 5, 2026
@Andy-Jost
Andy-Jost requested a review from leofang February 5, 2026 18:51
Comment thread cuda_bindings/setup.py
return cythonize(
extensions,
nthreads=nthreads,
build_dir="build/cython",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required to avoid including the source?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this places generated .cpp files outside of the source tree

@Andy-Jost Andy-Jost added the cuda.core Everything related to the cuda.core module label Feb 5, 2026
@Andy-Jost
Andy-Jost requested a review from rparolin February 5, 2026 18:52
@Andy-Jost Andy-Jost added cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements labels Feb 5, 2026
@Andy-Jost
Andy-Jost requested a review from rwgk February 5, 2026 18:52
@Andy-Jost

Copy link
Copy Markdown
Contributor Author

/ok to test 15cc9f5

@github-actions

This comment has been minimized.

@Andy-Jost
Andy-Jost enabled auto-merge (squash) February 5, 2026 19:12
@Andy-Jost
Andy-Jost merged commit eec6988 into NVIDIA:main Feb 5, 2026
173 of 175 checks passed
@github-actions

This comment has been minimized.

@Andy-Jost
Andy-Jost deleted the fix-cpp-in-wheel branch February 5, 2026 20:14
@github-actions

github-actions Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor
Doc Preview CI
Preview removed because the pull request was closed or merged.

@kkraus14

kkraus14 commented Feb 7, 2026

Copy link
Copy Markdown
Collaborator

We need to backport this to branch 12.9.x as well.

@kkraus14 kkraus14 added the to-be-backported Trigger the bot to raise a backport PR upon merge label Feb 7, 2026
@github-actions

github-actions Bot commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Backport failed for 12.9.x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 12.9.x
git worktree add -d .worktree/backport-1578-to-12.9.x origin/12.9.x
cd .worktree/backport-1578-to-12.9.x
git switch --create backport-1578-to-12.9.x
git cherry-pick -x eec6988faf9c0129f327f6da16f42b6b5aee4b60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module enhancement Any code-related improvements to-be-backported Trigger the bot to raise a backport PR upon merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants