Skip to content

Declare free-threading support, and test on Python 3.14t - #14

Merged
artem-ogre merged 1 commit into
artem-ogre:masterfrom
aidannewsome:free-threading
Oct 4, 2026
Merged

artem-ogre merged 1 commit into
artem-ogre:masterfrom
aidannewsome:free-threading

Conversation

@aidannewsome

Copy link
Copy Markdown
Contributor

Triangulation already releases the GIL and guards each instance with its own mutex, so the module is safe to use without the GIL. It just doesn't declare that, so importing PythonCDT on a free-threaded Python turns the GIL back on for the whole process.

  • Declare it: PYBIND11_MODULE(PythonCDT, m, py::mod_gil_not_used()).
  • Add Python 3.14t to the CI matrix, so the tests run free-threaded.

On Python 3.14t the GIL stays off after import, all 27 tests pass, and benchmark_gil_release.py gives a 5.5x speedup on 8 threads.

CI passes on my fork: https://github.com/aidannewsome/PythonCDT/actions/runs/37171486611

Triangulation already releases the GIL and guards each instance with its
own mutex, so the module is safe without the GIL. Without the declaration,
importing PythonCDT on a free-threaded Python turns the GIL back on for the
whole process.
@artem-ogre

Copy link
Copy Markdown
Owner

Thank you, Aidan! Looks good to me.

@artem-ogre
artem-ogre merged commit c35257a into artem-ogre:master Oct 4, 2026
@aidannewsome

Copy link
Copy Markdown
Contributor Author

Thanks Artem!

@aidannewsome
aidannewsome deleted the free-threading branch October 4, 2026 13:04
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>
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.

2 participants