Skip to content

Fix wheel ABI: produce .abi3.so to match cp312-abi3 wheel tag#116

Merged
tohtsky merged 1 commit into
tohtsky:mainfrom
marevol:feature/abi3-stable-naming
May 15, 2026
Merged

Fix wheel ABI: produce .abi3.so to match cp312-abi3 wheel tag#116
tohtsky merged 1 commit into
tohtsky:mainfrom
marevol:feature/abi3-stable-naming

Conversation

@marevol
Copy link
Copy Markdown
Contributor

@marevol marevol commented May 14, 2026

Summary

scikit-build-core tags wheels as cp312-abi3 via wheel.py-api = "cp312" in pyproject.toml, but nanobind_add_module(...) without STABLE_ABI produces version-specific .cpython-3X-<platform>.so files. The resulting wheel claims abi3 compatibility in its filename but fails to load on Python 3.13/3.14 because the inner .so files use a CPython-3.12-only extension suffix:

>>> from irspack.evaluation import EvaluatorCore
ModuleNotFoundError: No module named 'irspack.evaluation._core_evaluator'

Root cause

nanobind_add_module(... STABLE_ABI ...) silently turns STABLE_ABI off when Python::SABIModule is not a CMake target (see nanobind-config.cmake L368-L373). scikit-build-core already sets SKBUILD_SABI_COMPONENT=Development.SABIModule, but the find_package(Python ...) call in CMakeLists.txt was not forwarding it, so the SABI target was never created.

Changes

  • Pass ${SKBUILD_SABI_COMPONENT} to find_package(Python ...) so the Python::SABIModule target exists for SABI builds.
  • Add STABLE_ABI to each nanobind_add_module call so extensions are compiled against the limited API and named .abi3.so.

Test plan

  • Local build on CPython 3.13.3 produces _core_evaluator.abi3.so etc.
  • Local build on CPython 3.14.5 produces _core_evaluator.abi3.so etc.
  • import irspack and from irspack.evaluation import EvaluatorCore succeed on both 3.13 and 3.14 from the cp312-abi3 wheel.
  • CI green on all supported Python versions.

scikit-build-core tags wheels as cp312-abi3 via `wheel.py-api = "cp312"`
in pyproject.toml, but `nanobind_add_module(...)` without `STABLE_ABI`
produces version-specific `.cpython-3X-darwin.so` files.  The resulting
wheel claims abi3 compatibility in its filename but fails to load on
Python 3.13/3.14 because the inner `.so` files use a CPython-3.12-only
extension suffix:

    >>> from irspack.evaluation import EvaluatorCore
    ModuleNotFoundError: No module named 'irspack.evaluation._core_evaluator'

Root cause: `nanobind_add_module(... STABLE_ABI ...)` silently turns
STABLE_ABI off when `Python::SABIModule` is not a target (see
nanobind-config.cmake L368-L373).  scikit-build-core already sets
`SKBUILD_SABI_COMPONENT=Development.SABIModule`, but our
`find_package(Python ...)` call wasn't forwarding it.

- Pass `${SKBUILD_SABI_COMPONENT}` to `find_package(Python ...)` so the
  `Python::SABIModule` target exists for SABI builds.
- Add `STABLE_ABI` to each `nanobind_add_module` call so extensions are
  compiled against the limited API and named `.abi3.so`.

Verified locally on CPython 3.13.3 and 3.14.5: produces
`_core_evaluator.abi3.so` etc., and downstream `irspack` imports succeed
on both interpreters.
@tohtsky
Copy link
Copy Markdown
Owner

tohtsky commented May 15, 2026

LGTM!

@tohtsky tohtsky merged commit 94af333 into tohtsky:main May 15, 2026
3 checks passed
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