Skip to content

Switch from pybind11 to nanobind #1851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Switch from pybind11 to nanobind #1851

wants to merge 3 commits into from

Conversation

cqc-alec
Copy link
Collaborator

@cqc-alec cqc-alec commented Apr 11, 2025

Closes #1800 .

It's not quite as bad as the diff size suggests: most of the changes are quite simple; the stub files are autogenerated; and stubgen.py is taken from the nanobind repo (hopefully temporarily, see below).

Wheels build tested here.

The nix build failure can be ignored.

There are a few follow-on tasks:

  • Try to eliminate the leaks that can apparently occur when Python exits because the garbage collector can't do its job properly. For the moment I've just repressed the warnings. (See https://nanobind.readthedocs.io/en/latest/refleaks.html .)
  • Make one or more PRs to the nanobind project with the customizations I've made to stubgen.py, so that we can actually use nanobind.stubgen instead of a modified copy.
  • Generate stable ABI pytket wheels.

@cqc-alec cqc-alec changed the title Ae/nanobind.4 Switch from pybind11 to nanobind Apr 11, 2025
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a straight copy of https://github.com/wjakob/nanobind/blob/master/src/stubgen.py with some adaptations which I will try to upstream so that we can then use nanobind.stubgen directly. The adaptations can be viewed here.

@cqc-alec cqc-alec marked this pull request as ready for review April 11, 2025 20:30
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.

Investigate switching from pybind11 to nanobind
1 participant