Skip to content

Limited API is still not fully supported in Python 3.15 #760

Description

@kytta

Describe the bug

#713 raised an issue that free-threaded wheels cannot be built because of the lack of Limited API. The fix was to disable Limited API on free-threaded 3.14 and below, with hope that it will become stable in 3.15:

aws-crt-python/setup.py

Lines 615 to 619 in 241be07

# prefer building with stable ABI, so a wheel can work with multiple major versions
if FREE_THREADED_BUILD and sys.version_info[:2] <= (3, 14):
# 3.14 free threaded (aka no gil) does not support limited api.
# disable it for now. 3.15 promises to support limited api + free threading combo
py_limited_api = False

This is sadly not the case. Using Python 3.15.0rc1+freethreaded (rc1 means the ABI will not be changed), there are still compilation errors (see below).

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Installing awscrt under Python 3.15t succeeds

Current Behavior

$ pip install -e .
...
/redacted/path/to/cpython315t/include/python3.15t/object.h:375:12:
      error: call to undeclared function 'Py_IS_TYPE'; ISO C99 and later do not support implicit function declarations
      [-Wimplicit-function-declaration]
        375 |     return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
            |            ^
      /redacted/path/to/cpython315t/include/python3.15t/object.h:375:53:
      error: call to undeclared function 'Py_TYPE'; ISO C99 and later do not support implicit function declarations
      [-Wimplicit-function-declaration]
        375 |     return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
            |                                                     ^
      /redacted/path/to/cpython315t/include/python3.15t/object.h:375:53:
      error: incompatible integer to pointer conversion passing 'int' to parameter of type 'PyTypeObject *' (aka 'struct _typeobject *')
      [-Wint-conversion]
        375 |     return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
            |                                                     ^~~~~~~~~~~
      /redacted/path/to/cpython315t/include/python3.15t/object.h:763:32:
      error: call to undeclared function 'Py_TYPE'; ISO C99 and later do not support implicit function declarations
      [-Wimplicit-function-declaration]
        763 |     return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS);
            |                                ^
      /redacted/path/to/cpython315t/include/python3.15t/object.h:763:12:
      error: incompatible integer to pointer conversion passing 'int' to parameter of type 'PyTypeObject *' (aka 'struct _typeobject *')
      [-Wint-conversion]
        763 |     return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS);
            |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /redacted/path/to/cpython315t/include/python3.15t/object.h:773:12:
      error: call to undeclared function 'Py_IS_TYPE'; ISO C99 and later do not support implicit function declarations
      [-Wimplicit-function-declaration]
        773 |     return Py_IS_TYPE(op, &PyType_Type);
            |            ^
      6 errors generated.

Reproduction Steps

I was using uv

git clone https://github.com/awslabs/aws-crt-python.git
cd aws-crt-python
git submodule update --init
uv venv -p 3.15t --seed
uv pip install -e .

Possible Solution

I propose we move the upper bound one version further:

diff --git a/setup.py b/setup.py
index bcf0b04..bc60ffe 100644
--- a/setup.py
+++ b/setup.py
@@ -613,9 +613,10 @@ def awscrt_ext():
                     extra_link_args += ['-Wl,--fatal-warnings']
 
     # prefer building with stable ABI, so a wheel can work with multiple major versions
-    if FREE_THREADED_BUILD and sys.version_info[:2] <= (3, 14):
+    if FREE_THREADED_BUILD and sys.version_info[:2] <= (3, 15):
         # 3.14 free threaded (aka no gil) does not support limited api.
-        # disable it for now. 3.15 promises to support limited api + free threading combo
+        # disable it for now. 3.15 does support limited api + free threading combo,
+        # but it's not complete yet
         py_limited_api = False
     elif sys.version_info >= (3, 13):
         # 3.13 deprecates PyWeakref_GetObject(), adds alternative

Additional Information/Context

No response

aws-crt-python version used

0.36.2

Python version used

3.15.0rc1+freethreaded

Operating System and version

macOS Sonoma 14.8.1 (23J30)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions