Repository navigation
Build wheels and publish to PyPI on release - #15
aidannewsome wants to merge 2 commits into
Conversation
…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.
|
The 32-bit Windows crash is in pybind11, not PythonCDT: any module that registers a structured dtype with |
|
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). |
|
@mdealencar sorry for not merging it back then, life got in the way |
…uilds the wheels without a failed publish
* 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>
|
@aidannewsome @mdealencar I've done this in #16 pip install pythoncdtimport pythoncdt as cdtPlease, any further feedback and suggestions are welcome! For instance I would probably need to put it on conda? |
|
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. |
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:cdt_bindings_test.py. Intel Macs install from the sdist.2.0.0, it also publishes everything to PyPI with trusted publishing, so no token is stored in the repository.pyproject.toml: cibuildwheel's tests now install numpy, which thetestextra does not, and copy the tests' input files fromCDT/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 PythonCDTthere (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:
PythonCDTartem-ogrePythonCDTwheels.ymlpypiThen publish a release as you do now, and the wheels go to PyPI.