Build limited-API (abi3) wheels: mark CFFI extension py_limited_api and remove wrong bdist_wheel hack#31
Closed
Build limited-API (abi3) wheels: mark CFFI extension py_limited_api and remove wrong bdist_wheel hack#31
Conversation
* python/doc/source/REFERENCES.bib, r/inst/REFERENCES.bib: Regenerate.
…or the rest. * .github/workflows/python.yml: Simplify wheels job. Build ubuntu-22.04-arm.
* python/benchmarks/python-requirements.txt: Add numba, sort lines.
* .github/windows_arm64_steps/action.yml: New.
…indows and -march=x86-64-v2 on x86-64 Linux and MacOS to enable basic vectorization.
Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Build limited-API wheels: mark CFFI extension py_limited_api
Build limited-API (abi3) wheels: mark CFFI extension py_limited_api and remove wrong bdist_wheel hack
Oct 17, 2025
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #31 +/- ##
==========================================
+ Coverage 72.17% 72.21% +0.03%
==========================================
Files 57 57
Lines 4856 4859 +3
Branches 929 929
==========================================
+ Hits 3505 3509 +4
- Misses 999 1000 +1
+ Partials 352 350 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Problem
The
setup.pyhad a custombdist_wheel_abi_noneclass that incorrectly forced the ABI tag to 'none', preventing the creation of proper limited-API (abi3) wheels. This resulted in wheels likemoocore-0.1.9.dev0-py3-none-linux_x86_64.whlthat couldn't take advantage of Python's stable ABI, requiring separate wheels for each Python version.Additionally,
_ffi_build.pyhad a bug whereextra_link_argswas set toextra_compile_argsinstead of the correctextra_link_argsvariable.Solution
Replaced the incorrect bdist_wheel override in
setup.pywithbdist_wheel_abi3that automatically detectspy_limited_api=Truefrom CFFI extension modules and sets the appropriate abi3 wheel tag (cp310-abi3).Marked the CFFI extension with
py_limited_api=Trueinsrc/moocore/_ffi_build.pyto enable limited API compilation.Fixed
extra_link_argsto use the correct variable instead of duplicatingextra_compile_args.Result
Wheels now correctly use the Python Limited API (abi3):
moocore-0.1.9.dev0-py3-none-linux_x86_64.whlwithTag: py3-none-linux_x86_64moocore-0.1.9.dev0-cp310-abi3-linux_x86_64.whlwithTag: cp310-abi3-linux_x86_64The generated shared library is now named
_libmoocore.abi3.so, confirming it was compiled with the limited API. This allows the same wheel to work across all Python 3.10+ versions without recompilation.Testing
Requirements
Requires recent versions of setuptools (>=77.0.3), wheel, and cffi (>=1.17.1) to properly propagate py_limited_api into wheel tags, as specified in
pyproject.toml.Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.