@@ -274,10 +274,7 @@ def finalize_options(self) -> None:
274
274
self .distribution .has_ext_modules () or self .distribution .has_c_libraries ()
275
275
)
276
276
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 ()
281
278
282
279
# Support legacy [wheel] section for setting universal
283
280
wheel = self .distribution .get_option_dict ("wheel" )
@@ -291,6 +288,21 @@ def finalize_options(self) -> None:
291
288
if self .build_number is not None and not self .build_number [:1 ].isdigit ():
292
289
raise ValueError ("Build tag (build-number) must start with a digit." )
293
290
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
+
294
306
@property
295
307
def wheel_dist_name (self ) -> str :
296
308
"""Return distribution full name with - replaced with _"""
0 commit comments