Skip to content

Commit

Permalink
Don't build with limited API for 3.13 free-threaded build (#2402)
Browse files Browse the repository at this point in the history
The `--disable-gil` configuration of CPython 3.13 does not currently
support the limited API.

Signed-off-by: Sam Gross <[email protected]>
  • Loading branch information
colesbury authored May 18, 2024
1 parent 3c518a3 commit 1c7cb0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
been reused. This makes `process_iter()`_ around 20x times faster.
- 2396_: a new ``psutil.process_iter.cache_clear()`` API can be used the clear
`process_iter()`_ internal cache.
- 2401_, Support building with free-threaded CPython 3.13.
- 2407_: `Process.connections()`_ was renamed to `Process.net_connections()`_.
The old name is still available, but it's deprecated (triggers a
``DeprecationWarning``) and will be removed in the future.
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import struct
import subprocess
import sys
import sysconfig
import tempfile
import warnings

Expand Down Expand Up @@ -65,6 +66,7 @@
PY37_PLUS = sys.version_info[:2] >= (3, 7)
CP36_PLUS = PY36_PLUS and sys.implementation.name == "cpython"
CP37_PLUS = PY37_PLUS and sys.implementation.name == "cpython"
Py_GIL_DISABLED = sysconfig.get_config_var("Py_GIL_DISABLED")

macros = []
if POSIX:
Expand Down Expand Up @@ -118,10 +120,10 @@ def get_version():

# Py_LIMITED_API lets us create a single wheel which works with multiple
# python versions, including unreleased ones.
if bdist_wheel and CP36_PLUS and (MACOS or LINUX):
if bdist_wheel and CP36_PLUS and (MACOS or LINUX) and not Py_GIL_DISABLED:
py_limited_api = {"py_limited_api": True}
macros.append(('Py_LIMITED_API', '0x03060000'))
elif bdist_wheel and CP37_PLUS and WINDOWS:
elif bdist_wheel and CP37_PLUS and WINDOWS and not Py_GIL_DISABLED:
# PyErr_SetFromWindowsErr / PyErr_SetFromWindowsErrWithFilename are
# part of the stable API/ABI starting with CPython 3.7
py_limited_api = {"py_limited_api": True}
Expand Down

0 comments on commit 1c7cb0a

Please sign in to comment.