From 15cc9f5db135f815fc5a6221ae8680a37cec2853 Mon Sep 17 00:00:00 2001 From: Andy Jost Date: Thu, 5 Feb 2026 10:46:06 -0800 Subject: [PATCH] Exclude Cython-generated .cpp files from wheels 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. --- cuda_bindings/pyproject.toml | 3 +++ cuda_bindings/setup.py | 1 + cuda_core/build_hooks.py | 1 + 3 files changed, 5 insertions(+) diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index 4b02aaa225..f851af87c9 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -56,6 +56,9 @@ Documentation = "https://nvidia.github.io/cuda-python/" [tool.setuptools.packages.find] include = ["cuda*"] +[tool.setuptools.exclude-package-data] +"*" = ["*.cpp"] + [tool.setuptools.dynamic] readme = { file = ["DESCRIPTION.rst"], content-type = "text/x-rst" } diff --git a/cuda_bindings/setup.py b/cuda_bindings/setup.py index bfa1ae7826..5b53ad0b1e 100644 --- a/cuda_bindings/setup.py +++ b/cuda_bindings/setup.py @@ -356,6 +356,7 @@ def do_cythonize(extensions): return cythonize( extensions, nthreads=nthreads, + build_dir="build/cython", compiler_directives=compiler_directives, **extra_cythonize_kwargs, ) diff --git a/cuda_core/build_hooks.py b/cuda_core/build_hooks.py index 4b1781b52d..5d615ad003 100644 --- a/cuda_core/build_hooks.py +++ b/cuda_core/build_hooks.py @@ -163,6 +163,7 @@ def get_sources(mod_name): ext_modules, verbose=True, language_level=3, + build_dir="build/cython", nthreads=nthreads, compiler_directives=compiler_directives, compile_time_env=compile_time_env,