feat: declare cdef public/api headers as outputs#93
Merged
Conversation
A .pyx with `cdef public` / `cdef api` declarations makes Cython write `<name>.h` / `<name>_api.h` next to the generated source. Add `PUBLIC_HEADER_VARIABLE` and `API_HEADER_VARIABLE` keywords to `cython_transpile` that declare those headers as additional outputs of the generating command and return their paths, so other targets can depend on them cleanly. Addresses item 1 of the first comment on #84. Assisted-by: ClaudeCode:claude-opus-4-8
henryiii
force-pushed
the
feat/header-outputs
branch
from
July 10, 2026 19:27
2930e88 to
20056a0
Compare
henryiii
marked this pull request as ready for review
July 12, 2026 02:59
Cython names cdef public/api headers and annotate HTML by replacing the output file's last extension (os.path.splitext), but NAME_WE strips the longest extension, so OUTPUT names like mod.generated.c declared and returned paths that were never created. Assisted-by: ClaudeCode:claude-fable-5
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.
🤖 AI text below 🤖
When a
.pyxusescdef public/cdef api, Cython writes<name>.h/<name>_api.hnext to the generated source, butcython_transpilenever declared them, so other targets could not depend on them and their paths were unknown.This adds two opt-in keywords,
PUBLIC_HEADER_VARIABLE <var>andAPI_HEADER_VARIABLE <var>. When given,cython_transpile:<out_dir>/<stem>.h,<out_dir>/<stem>_api.h, matching where Cython actually writes them),OUTPUTof the generating command so downstream targets can depend on it, andExplicit keywords were chosen over auto-detection: scanning the source for
cdef public/cdef apiis fragile (comments, strings,.pxdincludes) and would silently declare outputs Cython may not emit.A new
public_headerstest fixture builds a separate C target that#includes the generated header (viaOBJECT_DEPENDS) and asserts both headers exist after the wheel build; it fails without the output declaration because the consumer races ahead of Cython.Docs comment block in
UseCython.cmakeandREADME.mdupdated.Addresses item 1 of the first comment on #84.