Skip to content

feat(core-cffi-hello): add cffi cffi-gen-src sample#78

Merged
henryiii merged 4 commits into
mainfrom
feat/core-cffi-hello
Jul 7, 2026
Merged

feat(core-cffi-hello): add cffi cffi-gen-src sample#78
henryiii merged 4 commits into
mainfrom
feat/core-cffi-hello

Conversation

@henryiii

@henryiii henryiii commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Adds core-cffi-hello, a scikit-build-core sample for cffi 2.1's new cffi-gen-src CLI — the scikit-build-core analog of the meson-python example in the cffi docs.

  • Uses the read-sources mode: the FFI definitions (_hello.cdef.txt) and C prelude (_hello.csrc.c) are separate files fed to python -m cffi.gen_src in an add_custom_command; the generated _hello.c is compiled with the plain C library via python_add_library. Compile/link flags live in CMake since cffi-gen-src ignores set_source()-style libraries=/include_dirs= arguments.
  • cffi stays a runtime dependency (_cffi_backend); the cdef/csrc inputs are excluded from the wheel but ship in the sdist.
  • Uses a PEP 639 SPDX license = "MIT" expression instead of a classifier.
  • Gated to Python 3.10+ in noxfile.py (cffi 2.1's floor), following the hello-free-threading pattern; listed in the top-level README and AGENTS.md.

Verified locally beyond CI: wheel/sdist contents inspected (cdef/csrc excluded from wheel, License-Expression: MIT in METADATA).

henryiii added 4 commits July 6, 2026 22:53
Adds a scikit-build-core sample using cffi 2.1's new cffi-gen-src CLI to
generate the extension source at build time, mirroring the meson-python
example in the cffi docs. Gated to Python 3.10+ in the noxfile since
cffi 2.1 requires it.

Assisted-by: ClaudeCode:claude-fable-5
Replaces the exec-python builder script with separate .cdef.txt/.csrc.c
inputs, the recommended form for build-system integration.

Assisted-by: ClaudeCode:claude-fable-5
cffi's generated source defines Py_LIMITED_API itself on MSVC release
builds, making pyconfig.h auto-link python3.lib, which fails when CMake
links the version-specific library. Lean in and build a proper abi3
wheel via wheel.py-api + USE_SABI.

Assisted-by: ClaudeCode:claude-fable-5
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii henryiii merged commit 0ad0bd7 into main Jul 7, 2026
14 checks passed
@henryiii henryiii deleted the feat/core-cffi-hello branch July 7, 2026 04:29
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