Skip to content

Commit 7dd3d6d

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

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

extension_helpers/_utils.py

Lines changed: 10 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,15 @@ 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+
vi = sys.version_info
166+
py_limited_api = f"cp{vi.major}{vi.minor}"
167+
else:
168+
py_limited_api = None
161169

170+
if py_limited_api is not None:
162171
if "DIST_EXTRA_CONFIG" in os.environ:
163172
raise ValueError(
164173
"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.3.0,<0.4.0",
2122
"setuptools>=64",
2223
"tomli>=1.0.0 ; python_version < '3.11'",
2324
]

0 commit comments

Comments
 (0)