# HG changeset patch # User Franz Glasner # Date 1641067385 -3600 # Node ID adf65c31f8fc789122d160e67389b9c0995585a1 # Parent 6501fe0e116cee8f3a190b27e42def1c1fa4002f Automatically select the proper API when building the speedup C-extension: Build the C-extension for Python 3.5+ and build against the stable API for Python 3.7+. diff -r 6501fe0e116c -r adf65c31f8fc setup.py --- a/setup.py Sat Jan 01 20:36:46 2022 +0100 +++ b/setup.py Sat Jan 01 21:03:05 2022 +0100 @@ -53,11 +53,16 @@ # PyPy does not need this. # +# The C-extension uses multi-phase module initialization (PEP 489, PY 3.5+) if (platform.python_implementation() == "CPython" and (sys.version_info[0] > 3 - or (sys.version_info[0] == 3 and sys.version_info[1] >= 7))): + or (sys.version_info[0] == 3 and sys.version_info[1] >= 5))): - py_limited_api = True + # The stable API for Python 3.7+ is used + if sys.version_info[0] == 3 and sys.version_info[1] < 7: + py_limited_api = False + else: + py_limited_api = True if py_limited_api: define_macros = [("Py_LIMITED_API", "0x03070000")]