Skip to content

Build limited-API (abi3) wheels: mark CFFI extension py_limited_api and remove wrong bdist_wheel hack#31

Closed
Copilot wants to merge 19 commits intomainfrom
copilot/fix-limited-api-wheels
Closed

Build limited-API (abi3) wheels: mark CFFI extension py_limited_api and remove wrong bdist_wheel hack#31
Copilot wants to merge 19 commits intomainfrom
copilot/fix-limited-api-wheels

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 17, 2025

Problem

The setup.py had a custom bdist_wheel_abi_none class that incorrectly forced the ABI tag to 'none', preventing the creation of proper limited-API (abi3) wheels. This resulted in wheels like moocore-0.1.9.dev0-py3-none-linux_x86_64.whl that couldn't take advantage of Python's stable ABI, requiring separate wheels for each Python version.

Additionally, _ffi_build.py had a bug where extra_link_args was set to extra_compile_args instead of the correct extra_link_args variable.

Solution

  1. Replaced the incorrect bdist_wheel override in setup.py with bdist_wheel_abi3 that automatically detects py_limited_api=True from CFFI extension modules and sets the appropriate abi3 wheel tag (cp310-abi3).

  2. Marked the CFFI extension with py_limited_api=True in src/moocore/_ffi_build.py to enable limited API compilation.

  3. Fixed extra_link_args to use the correct variable instead of duplicating extra_compile_args.

Result

Wheels now correctly use the Python Limited API (abi3):

  • Before: moocore-0.1.9.dev0-py3-none-linux_x86_64.whl with Tag: py3-none-linux_x86_64
  • After: moocore-0.1.9.dev0-cp310-abi3-linux_x86_64.whl with Tag: cp310-abi3-linux_x86_64

The 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

  • Built wheel successfully with correct abi3 tags in both filename and WHEEL metadata
  • All 35 existing tests pass
  • Editable installs also correctly generate abi3 wheels

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

Open a pull request from branch fix/abi3-wheels into main with title 'Build limited-API (abi3) wheels: mark CFFI extension py_limited_api and remove wrong bdist_wheel hack' and body 'Problem: setup.py had a custom bdist_wheel override that set the ABI tag to 'none', preventing proper limited-API (abi3) wheels. Fix: removed the incorrect bdist_wheel override, marked the CFFI extension with py_limited_api=True in src/moocore/_ffi_build.py, and fixed extra_link_args so link flags are applied correctly. Verification: build a wheel (python -m pip wheel . in python/) and confirm the wheel filename and WHEEL file contain py3-abi3-. Notes: Requires recent setuptools/wheel/cffi to propagate py_limited_api into wheel tags.'


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

MLopez-Ibanez and others added 18 commits October 16, 2025 13:08
 * 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
Copilot AI requested a review from MLopez-Ibanez October 17, 2025 16:06
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.21%. Comparing base (25d4939) to head (c69566e).
⚠️ Report is 15 commits behind head on main.

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     
Flag Coverage Δ
python 71.19% <81.81%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
tests 100.00% <ø> (ø)
src 85.67% <81.81%> (-0.22%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MLopez-Ibanez MLopez-Ibanez deleted the copilot/fix-limited-api-wheels branch November 2, 2025 10:55
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