Skip to content

Commit 57379cd

Browse files
authored
Prevent abi3 from being used with no-GIL interpreter (#4424)
2 parents 6fcce38 + 13e43c6 commit 57379cd

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

newsfragments/4420.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Raises an exception when ``py_limited_api`` is used in a build with
2+
``Py_GIL_DISABLED``. This is currently not supported (python/cpython#111506).

setuptools/command/bdist_wheel.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,7 @@ def finalize_options(self) -> None:
274274
self.distribution.has_ext_modules() or self.distribution.has_c_libraries()
275275
)
276276

277-
if self.py_limited_api and not re.match(
278-
PY_LIMITED_API_PATTERN, self.py_limited_api
279-
):
280-
raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'")
277+
self._validate_py_limited_api()
281278

282279
# Support legacy [wheel] section for setting universal
283280
wheel = self.distribution.get_option_dict("wheel")
@@ -291,6 +288,21 @@ def finalize_options(self) -> None:
291288
if self.build_number is not None and not self.build_number[:1].isdigit():
292289
raise ValueError("Build tag (build-number) must start with a digit.")
293290

291+
def _validate_py_limited_api(self) -> None:
292+
if not self.py_limited_api:
293+
return
294+
295+
if not re.match(PY_LIMITED_API_PATTERN, self.py_limited_api):
296+
raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'")
297+
298+
if sysconfig.get_config_var("Py_GIL_DISABLED"):
299+
raise ValueError(
300+
f"`py_limited_api={self.py_limited_api!r}` not supported. "
301+
"`Py_LIMITED_API` is currently incompatible with "
302+
f"`Py_GIL_DISABLED` ({sys.abiflags=!r}). "
303+
"See https://github.com/python/cpython/issues/111506."
304+
)
305+
294306
@property
295307
def wheel_dist_name(self) -> str:
296308
"""Return distribution full name with - replaced with _"""

0 commit comments

Comments
 (0)