Fix wheel ABI: produce .abi3.so to match cp312-abi3 wheel tag#116
Merged
Conversation
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.
Owner
|
LGTM! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scikit-build-core tags wheels as
cp312-abi3viawheel.py-api = "cp312"inpyproject.toml, butnanobind_add_module(...)withoutSTABLE_ABIproduces version-specific.cpython-3X-<platform>.sofiles. The resulting wheel claims abi3 compatibility in its filename but fails to load on Python 3.13/3.14 because the inner.sofiles use a CPython-3.12-only extension suffix:Root cause
nanobind_add_module(... STABLE_ABI ...)silently turnsSTABLE_ABIoff whenPython::SABIModuleis not a CMake target (seenanobind-config.cmakeL368-L373). scikit-build-core already setsSKBUILD_SABI_COMPONENT=Development.SABIModule, but thefind_package(Python ...)call inCMakeLists.txtwas not forwarding it, so the SABI target was never created.Changes
${SKBUILD_SABI_COMPONENT}tofind_package(Python ...)so thePython::SABIModuletarget exists for SABI builds.STABLE_ABIto eachnanobind_add_modulecall so extensions are compiled against the limited API and named.abi3.so.Test plan
_core_evaluator.abi3.soetc._core_evaluator.abi3.soetc.import irspackandfrom irspack.evaluation import EvaluatorCoresucceed on both 3.13 and 3.14 from the cp312-abi3 wheel.