Conversation
Contributor
Contributor
Author
|
/ok to test 41c8db9 |
Add an opt-in Cython cache behind CUDA_PYTHON_CYTHON_CACHE_DIR for cuda.bindings and cuda.core builds. When unset, cythonize() is called without cache= and builds are unchanged. POSIX only; Windows returns None with a warning. _cython_cache_path namespaces the cache by package, Python version, and a SHA-256 of output-affecting config (compiler_directives, compile_time_env, language_level, cplus, debug, cuda_major). This works around cython/cython#7532 (Cython omits compiler_directives from its native fingerprint); the helper and its tests can be removed once that issue is fixed in a released Cython version covered by cuda-python's minimum. _stable_cython_alias creates package-local directory symlinks (.cython-stdlib, and .cython-bindings for cuda.core) before cythonize() and removes them in finally, giving Cython stable relative include paths across PEP 517 builds that install deps under randomized temp prefixes. The two helpers are vendored in both build_hooks.py files (PEP 517 isolation forbids a shared import) and kept in sync by the existing pre-commit hook toolshed/check_build_hooks_sync.py, now covering one merged "shared build helpers" block instead of the toolchain-only block. No runtime drift test. Tests live in cuda_python_test_helpers/cython_cache.py (shared mixins + miss/hit smoke test + cross-isolated-env cache-hit regression) and are exercised by both packages' tests/test_build_hooks.py. POSIX-only tests skip on Windows; a Windows-only test asserts the set-env warn+None path.
juenglin
force-pushed
the
opt-in-cython-cache
branch
from
September 22, 2026 21:54
41c8db9 to
c929252
Compare
Contributor
Author
|
/ok to test c929252 |
juenglin
marked this pull request as ready for review
September 22, 2026 21:56
Contributor
|
rwgk
approved these changes
Sep 22, 2026
rwgk
left a comment
Contributor
There was a problem hiding this comment.
Approving, based on several stages of reviewing with codex gpt-5.6-sol medium. There are no findings anymore.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of #2903 (
toolchain-override-backend). Merge after #2903.Summary
Adds an opt-in Cython generated-source cache behind
CUDA_PYTHON_CYTHON_CACHE_DIRforcuda.bindingsandcuda.corebuilds. When unset,cythonize()is called withoutcache=and builds are unchanged. POSIX only; on Windows the helper returnsNonewith a warning.Two problems it works around:
_cython_cache_path): Cython's native fingerprint omitscompiler_directives([BUG] Cache fingerprinting ignorescompiler_directivescython/cython#7532). The helper namespaces the cache by package, Python version, and a SHA-256 of output-affecting config (compiler_directives,compile_time_env,language_level,cplus,debug,cuda_major). The helper and its workaround-specific tests can be removed once #7532 is fixed in a released Cython version covered by cuda-python's minimum._stable_cython_alias): Cython hashes the absolute path of each resolved.pxd, and PEP 517 installs land under randomized temp prefixes. Atomic package-local directory symlinks (.cython-stdlib, and.cython-bindingsfor cuda.core) give Cython stable relative include paths; created beforecythonize()and removed infinally.Sync mechanism
The two helpers are vendored in both
build_hooks.pyfiles (PEP 517 isolation forbids a shared import). Drift is enforced by the existing pre-commit hooktoolshed/check_build_hooks_sync.py, which now checks one merged "shared build helpers" block (toolchain + cache helpers) instead of the toolchain-only block. There is no runtime drift test.Tests
Shared tests live in
cuda_python_test_helpers/cuda_python_test_helpers/cython_cache.py(mixins, miss/hit smoke test, cross-isolated-env cache-hit regression) and are exercised by both packages'tests/test_build_hooks.py. POSIX-only tests skip on Windows; a Windows-only test asserts the set-env warn +Nonepath.Notes
cuda.corekeeps its existing per-configurationbuild_dir(cu{major}-{toolchain}-{debug|opt}[-cov]); onlycache=/include_pathwere added.CUDA_PYTHON_CYTHON_CACHE_DIRis intentionally not documented inenvironment_variables.rst; it joinsCUDA_PYTHON_TOOLCHAINunder the "no support guarantee" comment in bothbuild_hooks.pyfiles.