Skip to content

Commit bd0bcf1

Browse files
committed
FEAT: add support for automatic abi3 version selection
1 parent df8a488 commit bd0bcf1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

extension_helpers/_utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from importlib.util import module_from_spec, spec_from_file_location
1010
from pathlib import Path
1111

12+
from runtime_introspect import runtime_feature_set
13+
1214
if sys.version_info >= (3, 11):
1315
import tomllib
1416
else:
@@ -157,8 +159,14 @@ def get_limited_api_option(srcdir):
157159

158160
py_limited_api = os.environ.get("EXTENSION_HELPERS_PY_LIMITED_API")
159161

160-
if py_limited_api is not None:
162+
if py_limited_api == "auto":
163+
fs = runtime_feature_set()
164+
if fs.supports("py-limited-api"):
165+
py_limited_api = f"cp{sys.version_info.major}{sys.version_info.minor}"
166+
else:
167+
py_limited_api = None
161168

169+
if py_limited_api is not None:
162170
if "DIST_EXTRA_CONFIG" in os.environ:
163171
raise ValueError(
164172
"Cannot use EXTENSION_HELPERS_PY_LIMITED_API if DIST_EXTRA_CONFIG is already defined"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ classifiers = [
1818
]
1919
requires-python = ">=3.10"
2020
dependencies = [
21+
"runtime-introspect>=0.2.0",
2122
"setuptools>=64",
2223
"tomli>=1.0.0 ; python_version < '3.11'",
2324
]

0 commit comments

Comments
 (0)