Replace setuptools/bundled-capnproto build with conan-py-build + CMake [looking for feedback] - #404
Replace setuptools/bundled-capnproto build with conan-py-build + CMake [looking for feedback]#404czoido wants to merge 33 commits into
Conversation
haata
left a comment
There was a problem hiding this comment.
Sorry for the delay, not sure why I didn't see this.
| settings = "os", "compiler", "build_type", "arch" | ||
|
|
||
| def requirements(self): | ||
| self.requires("capnproto/1.0.1") |
There was a problem hiding this comment.
This part isn't clear to me.
Is it looking for the system library libcapnproto 1.0.1? Or is it trying to download 1.0.1?
It's not clear to me how this setup supports either using a system provided libcapnproto or using a bundled libcapnproto that is built and bundled together with pycapnp.
There was a problem hiding this comment.
See this page for the current workflows that are supported: https://capnproto.github.io/pycapnp/install.html#from-source
There was a problem hiding this comment.
self.requires("capnproto/<version>") always resolves through Conan: it pulls the package from Conan Center Index, downloading a prebuilt binary if one matches, or building it from source otherwise, it doesn't pick up an already-installed system libcapnp.
So yes, this drops the "system-installed libcapnp" workflow that install.html#from-source documents today, but it's possible to support a similar workflow with some changes.
There was a problem hiding this comment.
Will this work for all the different architectures that are currently supported? And for the various glibc/musl forms? Basically, we have to be careful with prebuilt. See here for the various versions supported today: https://pypi.org/project/pycapnp/2.2.4/#files
There was a problem hiding this comment.
Yes, it works. I compared the 98 wheels produced by this PR's CI run against the 98 wheels currently published on PyPI for 2.2.4 and filenames match exactly: same manylinux_2_28/musllinux_1_2 for x86_64/i686/aarch64/ppc64le/s390x, same macOS x86_64/arm64, same Windows win32/win_amd64, all CPython versions including cp314t. Nothing missing.
The backend always builds the capnproto package with --build=missing, so when Conan Center has no matching prebuilt (the normal case for musllinux), it compiles capnproto from source in that same container against its actual glibc/musl.
There was a problem hiding this comment.
I've recently updated pyproject.toml so some of this may need to be updated.
There was a problem hiding this comment.
Thanks, I have just updated the PR merging the changes
There was a problem hiding this comment.
Now that setup.py can be laid to rest (yay!), what's the equivalent for python setup.py clean?
There was a problem hiding this comment.
I think clean existed because the Cython build wrote generated files straight into the capnp/ source tree (capnp/lib/capnp.cpp, capnp/lib/capnp.h, etc.).
With the changes, nothing lands in the source tree anymore, the generated Cython .cpp, the capnproto build, and the copied schemas all stay inside CMake's/Conan's own folders. So no dedicated command should be needed.
There was a problem hiding this comment.
In that case it would be good to have a note in the document on what clean would be (i.e. what the default command to clean things up).
No worries at all, thanks for taking the time to review it! |
Hi from the Conan team!
We recently released conan-py-build, a PEP 517 build backend that uses Conan to manage C/C++ dependencies, and we're testing it on several popular Python extensions that we think could benefit from it.
Here's the launch blog post: https://blog.conan.io/cpp/conan/python/2026/05/05/Introducing-conan-py-build.html
And the repo and docs: https://github.com/conan-io/conan-py-build · https://conan-py-build.conan.io/
We wanted to share this port of
pycapnptoconan-py-buildto get some comments and feedback from the project. ThecapnprotoC++ library is fetched from Conan Center Index instead of being downloaded as a tarball fromcapnproto.orgat build time.This is a draft PR for sharing the work to get your thoughts on whether this direction is interesting to the project.
Some notes about the migration:
setup.pypreviously downloadedcapnproto-c++-1.0.1.tar.gzfromcapnproto.orgat build time. Conan now fetches and buildscapnproto/1.0.1from Conan Center Index.capnprotorequires autotools (m4, etc.) to be present on the system. Conan manages these build tools as well.conanfile.py.setup.py+buildutils/removed. ~350 lines of build machinery replaced by a minimalconanfile.pyand a standardCMakeLists.txt.capnp/version.pysimplified. Previously generated dynamically bysetup.py; now it's a static file usingimportlib.metadata.cibuildwheelkeeps driving multi-platform builds with minimal changes.CI results: https://github.com/czoido/pycapnp/actions/runs/27526912439
Any feedback is very welcome!
Thanks a lot 🙂