pypa / pypa/setuptools

[FR] Implicitly disable `py_limited_api` on Python 3.13 freethreaded

Open
#4,673 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Needs Triage
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

What's the problem this feature will solve?

Currently, enablng py_limited_api=True on Python 3.13 freethreaded results in hard failure.

Describe the solution you'd like

I think setuptools should fall back to building a regular (i.e. non-limited API) extension when Python 3.13 freethreading is used, just like it does for PyPy3 (that does not support the stable ABI). This also means removing Py_LIMITED_API macro from define_macros, which is a bit yucky.

Alternative Solutions

Right now, the main alternative is to special-case freethreading in every package separately, and do not enable the limited API if it's used. However, besides a lot of repetition, this means that every project would explicitly need to track the stable ABI support in freethreading builds, and update the special cases when it's implemented.

Alternatively, instead of removing py_limited_api and Py_LIMITED_API macros, we could change CPython to ignore it and use the regular API (just like PyPy does). However, this would mean that old versions of setuptools would still be producing abi3 wheels for that.

Additional context

Related to #4420, and python/cpython#111506 for the wider issue.

Code of Conduct
  • I agree to follow the PSF Code of Conduct

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named. Start by tracing setuptools handling of py_limited_api and the Py_LIMITED_API macro, then read related issue #4420 and python/cpython#111506; done means Python 3.13 freethreaded builds use the regular API rather than producing an abi3 extension.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.