Skip to content

Build wheels and publish to PyPI on release - #15

Closed
aidannewsome wants to merge 2 commits into
artem-ogre:masterfrom
aidannewsome:pypi-wheels
Closed

aidannewsome wants to merge 2 commits into
artem-ogre:masterfrom
aidannewsome:pypi-wheels

Conversation

@aidannewsome

@aidannewsome aidannewsome commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6. Builds on #8 by @mdealencar, which now conflicts with master and uses a cibuildwheel too old for Python 3.14.

This adds one workflow and two lines to pyproject.toml:

  • On every pull request it builds an sdist and wheels with cibuildwheel 4.3, for every CPython it supports, free-threaded included: Linux (glibc and musl, x86-64 and ARM), Windows x86-64, and macOS on Apple silicon. Each wheel is tested with cdt_bindings_test.py. Intel Macs install from the sdist.
  • When a GitHub release is published, with a tag such as 2.0.0, it also publishes everything to PyPI with trusted publishing, so no token is stored in the repository.
  • Publishing only runs in this repository, so a fork's release builds the wheels without a failed PyPI step.
  • pyproject.toml: cibuildwheel's tests now install numpy, which the test extra does not, and copy the tests' input files from CDT/visualizer/data, which they read by paths relative to the project.

Green run on my fork: https://github.com/aidannewsome/PythonCDT/actions/runs/37484656515

32-bit Windows is left out. Free-threaded Python 3.15.0rc3 crashed with an access violation on import PythonCDT there (https://github.com/aidannewsome/PythonCDT/actions/runs/37481594773), while 3.14t on 32-bit and 3.15t on 64-bit passed. I am narrowing it down to report it to CPython or pybind11.

To publish, once on pypi.org, under Your projects → Publishing → Add a new pending publisher → GitHub:

  • PyPI Project Name: PythonCDT
  • Owner: artem-ogre
  • Repository name: PythonCDT
  • Workflow name: wheels.yml
  • Environment name: pypi

Then publish a release as you do now, and the wheels go to PyPI.

…e is published

Wheels for every CPython cibuildwheel supports, free-threaded included, on Linux
(glibc and musl, x86-64 and ARM), Windows x86-64 and macOS on Apple silicon, each
tested with cdt_bindings_test.py, and an sdist. Publishing uses PyPI trusted
publishing, so no token is stored.

cibuildwheel's tests also need numpy, which the test extra does not install, and
the tests' input files, which they read by paths relative to the project.
@aidannewsome

Copy link
Copy Markdown
Contributor Author

The 32-bit Windows crash is in pybind11, not PythonCDT: any module that registers a structured dtype with PYBIND11_NUMPY_DTYPE crashes on import on free-threaded Python 3.15 for 32-bit Windows, with pybind11 3.0.4 and 3.1.0. Reported as pybind/pybind11#6196.

@mdealencar

Copy link
Copy Markdown
Contributor

I hope this gets merged this time. I ended up releasing package condeltri, you can check the differences in build/workflow approach in https://github.com/mdealencar/PythonCDT/tree/ConDelTri (I dropped setup.py and git submodules).

@artem-ogre

artem-ogre commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

@mdealencar sorry for not merging it back then, life got in the way

@artem-ogre artem-ogre mentioned this pull request Oct 6, 2026
artem-ogre added a commit that referenced this pull request Oct 6, 2026
Their pull requests (#8, #14 and #15) shaped how PythonCDT is packaged
and published to PyPI.

Co-authored-by: Mauricio Souza de Alencar <856825+mdealencar@users.noreply.github.com>
Co-authored-by: Aidan Newsome <32934243+aidannewsome@users.noreply.github.com>
artem-ogre added a commit that referenced this pull request Oct 6, 2026
* Package for PyPI with scikit-build-core

Replace setup.py with scikit-build-core and move the metadata into
pyproject.toml. The setuptools sdist contained no sources; the new one
includes the CDT submodule and builds on its own. pybind11 now comes from
the build requirements instead of a submodule, numpy is declared as a
dependency, and Python 3.10 or newer is required.

Rename the package to pythoncdt and make it a package with the compiled
module as pythoncdt._core, so that it can ship type stubs (_core.pyi and
py.typed). CI checks the stubs against the module with mypy.stubtest.

Build wheels with cibuildwheel for Linux, macOS and Windows, and publish
them to PyPI with trusted publishing when a GitHub release is published.
Run the tests on several threads at once on free-threaded Python.

Declare the package and its free-threading support stable.

* Take the version from git tags, and draft releases with Release Drafter

The version is no longer set in pyproject.toml: setuptools-scm takes it
from the git tag, so publishing a GitHub release tagged 2.1.0 publishes
version 2.1.0 to PyPI. Builds between releases get dev versions.

Release Drafter keeps a draft of the next release, listing the merged
pull requests and choosing the version from their labels: major, minor,
or patch when unlabeled. Publishing the draft releases it.

* Lint and format with ruff, enforced by pre-commit

Add pre-commit hooks running ruff's linter and formatter, and a CI job
running the same hooks so that unformatted or failing code can't be
merged. Fix what the linter found and reformat the tests.

* Simplify the version define and the test checksums

CMake passes the version as a string literal, so the stringify macros and
the "dev" fallback are gone. The tests hash the OFF text in memory instead
of writing it to a temporary file.

* Update CDT to 2.0.1

The update only bumps CDT's version and its docs, so the bindings need no
changes.

* Fix the V2d and Edge buffers, and the version in CI

The V2d and Edge buffers had twice the item size as stride, so the second
item was read past the end of the object, and Edge reported its items as
doubles. Their constructors read past short buffers and ignored strides.
They now reuse the checks of the insert overloads, and the Edge buffer is
read-only so that it can't break the v1 < v2 order.

The stubs declare __buffer__ for both classes, so type checkers accept
them as buffers.

CI fetches the full history, so the test builds get the version from the
git tags.

* Credit the packaging contributors

Their pull requests (#8, #14 and #15) shaped how PythonCDT is packaged
and published to PyPI.

Co-authored-by: Mauricio Souza de Alencar <856825+mdealencar@users.noreply.github.com>
Co-authored-by: Aidan Newsome <32934243+aidannewsome@users.noreply.github.com>

* Publish to PyPI only from artem-ogre/PythonCDT, so a fork's release builds the wheels without a failed publish

---------

Co-authored-by: Mauricio Souza de Alencar <856825+mdealencar@users.noreply.github.com>
Co-authored-by: Aidan Newsome <32934243+aidannewsome@users.noreply.github.com>
Co-authored-by: aidannewsome <aidan.newsome@me.com>
@artem-ogre

Copy link
Copy Markdown
Owner

@aidannewsome @mdealencar I've done this in #16
Thank you so much, gentlemen! 🍻
https://pypi.org/project/pythoncdt/

pip install pythoncdt
import pythoncdt as cdt

Please, any further feedback and suggestions are welcome! For instance I would probably need to put it on conda?

@artem-ogre artem-ogre closed this Oct 6, 2026
@aidannewsome
aidannewsome deleted the pypi-wheels branch October 7, 2026 01:11
@aidannewsome

Copy link
Copy Markdown
Contributor Author

No problem, and thanks for publishing it. It makes things much easier on my side.

On conda: I'm happy to set it up if you'd like. I've prepared a conda-forge recipe that builds from the PyPI sdist: https://github.com/aidannewsome/staged-recipes/tree/pythoncdt/recipes/pythoncdt. If you're OK with it, I'll submit it to conda-forge/staged-recipes with you as the maintainer. After that, conda-forge's bot opens a PR on the feedstock for each new PyPI release, so you keep releasing to PyPI as usual and merge those bot PRs. Your call. If you'd rather not or would rather do it yourself, that's fine too.

For a second maintainer, I'm happy to be listed, though I don't use conda myself. @mdealencar might be a better fit, as he already maintains condeltri on conda-forge.

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.

Releases

3 participants