Skip to content

Pin the numpy C API level - #42

Merged
lukeshingles merged 1 commit into
mainfrom
numpy-no-deprecated-api
Aug 9, 2026
Merged

Pin the numpy C API level#42
lukeshingles merged 1 commit into
mainfrom
numpy-no-deprecated-api

Conversation

@lukeshingles

Copy link
Copy Markdown
Member

Adds NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION to the extension's define_macros.

Without it the extension compiles against whatever numpy currently exposes, including APIs numpy has already deprecated. That means a future numpy removing one of them shows up as a broken build — or a broken wheel — at whatever moment numpy happens to release. With the guard, using a deprecated API becomes a compile error here, on our schedule rather than theirs.

Result

This was the change most likely to fail outright, since enabling the guard surfaces any deprecated usage as an error. It doesn't: the code uses no deprecated numpy API.

The define is visibly applied to both translation units:

clang ... -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION ... -c extern/bs.c
clang ... -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION ... -c src/extinction/_extinction.c

and the build produces no new warnings or errors — including from the Cython-generated C, which is the part most likely to reach for older numpy APIs.

NPY_1_7_API_VERSION is the level numpy documents for this purpose; it is the floor the code is held to, not a cap on the numpy version, and builds continue to use numpy 2 headers as before.

Verification

  • Wheel builds cleanly with the guard applied to both C sources.
  • 9/9 tests pass against the resulting wheel from an unrelated working directory.

🤖 Generated with Claude Code

Without NPY_NO_DEPRECATED_API the extension compiles against whatever
numpy currently exposes, including APIs numpy has already deprecated, so
a future removal surfaces as a broken build or a broken wheel at the
worst possible moment. Setting it makes that a compile error here, on
our schedule.

The code turns out not to use any deprecated API: the build is clean
with the guard in place, no new warnings, and the suite passes against
the resulting wheel.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Pins the extension to NumPy’s non-deprecated C API baseline to catch deprecated usage during compilation.

Changes:

  • Defines NPY_NO_DEPRECATED_API at the NumPy 1.7 API level.
  • Applies the macro to all extension translation units.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@lukeshingles
lukeshingles merged commit fa8812b into main Aug 9, 2026
19 checks passed
@lukeshingles
lukeshingles deleted the numpy-no-deprecated-api branch August 9, 2026 21:41
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.

2 participants