awslabs / awslabs/aws-crt-python

Limited API is still not fully supported in Python 3.15

Open Beginner friendly
#760 2 comments 0 reactions 0 assignees View on GitHub
bug needs-triage
Dominant language
Python
Stars
100
Forks
58
Avg merge
13h 51m
Merged PRs (30d)
2

Description

### Describe the bug

https://github.com/awslabs/aws-crt-python/issues/713 raised an issue that free-threaded wheels cannot be built because of the lack of Limited API. [The fix](https://github.com/awslabs/aws-crt-python/pull/725) was to disable Limited API on free-threaded 3.14 and below, with hope that it will become stable in 3.15:

https://github.com/awslabs/aws-crt-python/blob/241be07f82ebd3031a812492443d545676cb2018/setup.py#L615-L619

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

```bash
$ 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

```sh
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
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)

Contributor guide

Open the contributing guide

Research direction

Start in setup.py around awscrt_ext(), especially the FREE_THREADED_BUILD and sys.version_info condition near lines 613-619. Reproduce with Python 3.15t using the uv environment and install commands in the issue, then verify that the limited-API setting allows the editable install to succeed without the reported compilation errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.