-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Switch bindings implementation to nanobind
#1526
Conversation
Removes Python 3.7 from the support matrix, since it does not support PEP590 vectorcalls. Bumps the `cibuildwheel` and `pypa-publish` actions to their latest available versions respectively.
The build file builds nanobind as a static `cc_library`. Currently, the git SHA points to HEAD, since some necessary features have not been included in a release yet.
Switches over the binding tool to `nanobind` from `pybind11`. Most changes in the build setup itself were drop-in replacements of existing code changed to nanobind names, no new concepts needed to be implemented. Sets the minimum required macOS to 10.14 for full C++17 support. Also, to avoid ambiguities in Bazel, build for macOS 11 on Mac ARM64.
Guards against unknown linker option errors by selecting required linker options for nanobind only on macOS, where they are relevant. Other changes: * Bump cibuildwheel action to v2.12.0 * Bump Bazel for aarch64 linux wheels to 6.0.0 * Remove C++17 flag from build files since it is present in setup.py `bazel build` command * Bump nanobind commit to current HEAD (TBD: Bump to next stable release)
a46120b
to
d3c940c
Compare
Hmm, I guess I need to pass the |
Guards compiler options behind a new `select` macro choosing between MSVC and not MSVC. Other changes: * Inject the proper C++17 standard cxxopt in the `setup.py` build command. * Bump nanobind to current HEAD. * Make `macos` a benchmark-wide condition, with public visibility to allow its use in the nanobind BUILD file.
52c0187
to
b6b795f
Compare
Since `benchmark::Counter` only has a constructor for `double`, the nanobind `nb::init_implicit` template cannot be used. Therefore, to support implicit construction from ints, we fall back to the `nb::implicitly_convertible` template instead.
b6b795f
to
61a925d
Compare
I fixed the MSVC breakage, which was due to (my) user error. Should be good to go now, binding test matrix is all green, other failures are due a downed apt mirror presumably. If you want, I can restructure the PR and split it up (e.g. carving out the CI parts), to make it easier to revert to |
thank you! |
Title is self-explanatory. This uses
nanobind
to build Python bindings for Google Benchmark instead ofpybind11
, with the following consequences:nanobind
is checked in as a bazel dep, currently at HEAD instead of a tag, because some features used to generate the GBM binding code have not made it into a release yet.For performance considerations and changes in contrast to the current implementation, see the discussion #1521.
(For reviewers: I am not sure of the options I gave in the nanobind BUILD file - I looked at what compile commands CMake generated in release mode for nanobind and went on from there.)
The bindings now also contain the state name from #1511.