Skip to content

Integrate cffi-buildtool into CFFI itself#241

Open
ngoldbaum wants to merge 1 commit intopython-cffi:mainfrom
ngoldbaum:integrate-buildtool
Open

Integrate cffi-buildtool into CFFI itself#241
ngoldbaum wants to merge 1 commit intopython-cffi:mainfrom
ngoldbaum:integrate-buildtool

Conversation

@ngoldbaum
Copy link
Copy Markdown
Contributor

Closes #47. Revives #76.

This adds a new subpackage for cffi named cffi.buildtool and a new CLI script distributed by CFFI named gen-cffi-src. Also adds new tests and documentation. See the new documentation and tests for usage details.

I realize that this is a big change that makes a number of opinionated choices. I'm very happy to adjust things to suit the maintainers' taste.

My ultimate goal here is to make it possible for projects using CFFI to use arbitrary build tools and remove the perceived tight coupling between CFFI and setuptools/distutils. If there isn't appetite to add the code in cffi-buildtool to CFFI itself, I'd also happily document how to depend on and use cffi-buildtool instead.

See inklesspen/cffi-buildtool#2 where I got @inklesspen's blessing to do this.

The is based on code and documentation that were originally written by Rose Davidson (@inklesspen on GitHub) for the cffi-buildtool project: https://github.com/inklesspen/cffi-buildtool.

This adds code and documentation that was originally written by Rose Davidson
(@inklesspen on GitHub) for the cffi-buildtool project: https://github.com/inklesspen/cffi-buildtool
@inklesspen
Copy link
Copy Markdown
Contributor

Just commenting here to confirm I give my full support for this upstreaming, and after a release is cut which includes these changes, I will mark my existing project as deprecated.

Also I'm available to answer any questions about the original code upon which this is based.

Copy link
Copy Markdown
Contributor Author

@ngoldbaum ngoldbaum left a comment

Choose a reason for hiding this comment

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

Some thoughts that occurred to me since yesterday and a typo fix

Comment thread doc/source/buildtool.rst
a CPython extension module. What they add is two convenient front-ends
-- one that executes an existing "build" Python script, and one that
reads a ``cdef`` and C prelude from two files. This tool enables
integrating with and build backend, such as `meson-python
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
integrating with and build backend, such as `meson-python
integrating with any build backend, such as `meson-python

Comment thread doc/source/buildtool.rst


A Worked Example Using ``meson-python``
=======================================
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe this should just link to the example projects in the tests to avoid duplication?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there's value in having it right there in the docs, personally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The files in this second example that are exact duplicates of the ones in the first example could probably be symlinks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, in my version of the project I used an actual (though very simple) C library in the example projects, using meson's subproject wrap support. Arguably that's a slightly more realistic example case than this little squaring library.

@mattip
Copy link
Copy Markdown
Contributor

mattip commented Apr 21, 2026

There is a clang-tsan failure

@ngoldbaum
Copy link
Copy Markdown
Contributor Author

@mattip see #242 and #243, the failure is unrelated.

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.

Document how to use meson to build a cffi cextension

3 participants