Skip to content

build: Always regenerate the Cython C source when building - #88

Open
kylebarron wants to merge 1 commit into
fix/oct-encode-overflowfrom
build/cython-force-regenerate
Open

kylebarron wants to merge 1 commit into
fix/oct-encode-overflowfrom
build/cython-force-regenerate

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

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.c when the .pyx or 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, after uv sync on Python 3.13 (numpy 2.5), this failed every time:

$ UV_PYTHON=3.9 uv run --isolated pytest   # numpy 2.0
util_cy.c: error: call to undeclared function '_PyUFuncObject_GET_ITEM_DATA'

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=True to cythonize. 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

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
kylebarron added this pull request to stack #91 October 5, 2026 21:52

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant