Skip to content
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

Implement stable ABI builds #5

Merged
merged 3 commits into from
Mar 6, 2024
Merged

Implement stable ABI builds #5

merged 3 commits into from
Mar 6, 2024

Conversation

nicholasjng
Copy link
Owner

Still in progress, the extension name is not correct yet (needs to be .abi3.so in the SABI case).

However, I'm not sure how this is solvable elegantly outside of a completely custom rule implementation for nanobind_extension.

Usage:

bazel build //src:my_ext --@rules_python//python/config_settings:python_version=$MAJOR.$MINOR[.$PATCH] --@nanobind_bazel//:py-limited-api=cp312

Currently only cp312 and cp313 are supported as targetable Python ABI versions.

Otherwise, the Python side has no way to access them, since apparently
transitive non-module dependencies are not accessible from bzlmod.

Means that flags are henceforth available as `@nanobind_bazel//:$FLAG`,
e.g. `@nanobind_bazel//:minsize`.

Adds a `--py-limited-api` flag that controls the SABI build target version.
Currently only cp3{12,13} are supported, because that's what nanobind
supports, but it might be possible to open this up if the limited API
version and the Python interpreter build version can be different.
Basically only supplies a single define per branch, or nothing if the
falseish option is given.

This is supposedly solvable more elegantly with transitions, but I have
not read up enough on it yet to apply it for this case.
@nicholasjng nicholasjng added the enhancement New feature or request label Mar 4, 2024
@nicholasjng
Copy link
Owner Author

@wjakob Could you explain why only CPython>=3.12 is supported for nanobind SABI builds? The oldest Python ABI selectable is 3.2 (with -DPy_LIMITED_API=0x03020000), is the constraint due to a nanobind implementation detail?

@wjakob
Copy link

wjakob commented Mar 5, 2024

Because nanobind depends on functionality that hasn't become part of the SABI until 3.12.

Also add more required config settings for stable ABI + unix (producing
a .abi3.so extension).
@nicholasjng
Copy link
Owner Author

Summary:

  1. The new alias produces the correctly named .abi3.so file in the stable ABI case.
  2. The produced nanobind_example wheel is SABI 3.12 compliant, tested with python -m abi3audit dist/nanobind_example_..._.whl.
  3. I have not managed to build wheels with the correct cp312-abi3 tag with either python -m build or python -m pip wheel, only using the legacy python setup.py bdist_wheel --py-limited-api=cp312. This is no doubt my own issue, and should be configurable in the former frontends as well. (Curiously, -C--py-limited-api=cp312 does nothing.)

I'm going to merge this for now, and restructure the settings into a helper later.

@nicholasjng nicholasjng merged commit 5c29b43 into master Mar 6, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants