Skip to content

Commit a007348

Browse files
committed
Select the stable ABI free-threaded builds
1 parent 4c087a4 commit a007348

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

Include/Python.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
#endif
4848

4949
#if defined(Py_GIL_DISABLED)
50-
# if defined(Py_LIMITED_API) && !defined(_Py_OPAQUE_PYOBJECT)
51-
# error "Py_LIMITED_API is not currently supported in the free-threaded build"
52-
# endif
53-
5450
# if defined(_MSC_VER)
5551
# include <intrin.h> // __readgsqword()
5652
# endif

Include/patchlevel.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,32 @@
6161
#define PYTHON_ABI_VERSION 3
6262
#define PYTHON_ABI_STRING "3"
6363

64+
65+
/* Stable ABI for free-threaded builds (introduced in PEP 803)
66+
is enabled by one of:
67+
- Py_TARGET_ABI3T, or
68+
- Py_LIMITED_API and Py_GIL_DISABLED.
69+
"Output" macros to be used internally:
70+
- Py_LIMITED_API (defines the subset of API we expose)
71+
- _Py_OPAQUE_PYOBJECT (additionally hides what's ABI-incompatible between
72+
free-threaded & GIL)
73+
(Don't use Py_TARGET_ABI3T directly; we merge into the above two here.
74+
We do set it for users' convenience though.)
75+
*/
76+
#if defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) \
77+
&& !defined(Py_TARGET_ABI3T)
78+
# define Py_TARGET_ABI3T Py_LIMITED_API
79+
#endif
80+
#if defined(Py_TARGET_ABI3T)
81+
# define _Py_OPAQUE_PYOBJECT
82+
# if !defined(Py_LIMITED_API)
83+
# define Py_LIMITED_API Py_TARGET_ABI3T
84+
# elif Py_LIMITED_API > Py_TARGET_ABI3T
85+
// if both are defined, use the *lower* version,
86+
// i.e. maximum compatibility
87+
# undef Py_LIMITED_API
88+
# define Py_LIMITED_API Py_TARGET_ABI3T
89+
# endif
90+
#endif
91+
6492
#endif //_Py_PATCHLEVEL_H

0 commit comments

Comments
 (0)