Repository navigation
build: Always regenerate the Cython C source when building - #88
Open
kylebarron wants to merge 1 commit into
Open
kylebarron wants to merge 1 commit into
kylebarron wants to merge 1 commit into
Conversation
Cython skips regenerating `util_cy.c` when it is newer than the `.pyx` and
its `.pxd` dependencies, judged by file timestamps. The generated C depends
on the numpy version in the build environment, but a cached numpy install
can have older timestamps than an existing C file. So after building with
one Python version, building from the same checkout for another one could
reuse C generated for a newer numpy and fail to compile. For example, after
`uv sync` on Python 3.13 (numpy 2.5),
`UV_PYTHON=3.9 uv run --isolated pytest` (numpy 2.0) failed with:
util_cy.c: error: call to undeclared function
'_PyUFuncObject_GET_ITEM_DATA'
Pass `force=True` to `cythonize`. Cython is already a build requirement, so
always regenerating only costs a second or two per build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kylebarron
added this pull request to stack #91
October 5, 2026 21:52
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.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Makes the build always regenerate the Cython C source. This affects development builds only, so it isn't in the CHANGELOG.
Why
Cython only regenerates
util_cy.cwhen the.pyxor its dependencies are newer than the existing C file. But the generated C also depends on the numpy version in the build environment, and a cached numpy install can have older file timestamps. So after building for one Python version, building from the same checkout for another could reuse C generated for a newer numpy and fail to compile. For example, afteruv syncon Python 3.13 (numpy 2.5), this failed every time:Installs from an sdist weren't affected: the published 0.5.0 sdist builds fine on Python 3.9 and 3.10.
Fix
Pass
force=Truetocythonize. Cython is already a build requirement, so always regenerating costs only a second or two per build.There's no pytest regression test, since this is about build state; the reproduction above is the test.
🤖 Written by Claude Code