You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Python] Add Stable ABI (abi3) support for Python 3.12+ (#23600)
Build Python bindings against the Limited C API (`Py_LIMITED_API`, PEP
384) so that a single wheel built with Python 3.12 works on all future
CPython versions. This reduces the total release artifact size.
The Limited API forbids direct access to CPython struct layouts and most
convenience macros. The main impact is replacing the NumPy C API (whose
headers use non-limited internals) with Python-level equivalents like
`numpy.frombuffer()` and `numpy.dtype()`, and using nanobind's
`type_slots()` to register buffer/sequence/mapping protocols instead of
casting to `PyHeapTypeObject`.
Limitations:
- Only CPython 3.12+. Per-version wheels are still built for 3.10-3.11.
- Free-threaded builds (3.13t) are excluded: the free-threaded ABI is
not yet stable.
- `Development.SABIModule` requires CMake 3.26+ (IREE minimum is 3.21),
so `IREE_ENABLE_PYTHON_STABLE_ABI` is OFF by default. setup.py
auto-enables it when building with CPython 3.12+. May want to bump it in
the future.
The existing release workflow already builds with Python 3.12 on all
platforms, so abi3 wheels are produced with no workflow changes. pkgci
only builds cp311 by default (no abi3).
The LLVM submodule includes cherry-picks of llvm/llvm-project PRs for
MLIR-side abi3 support.
Assisted-by: claude
0 commit comments