@@ -275,19 +275,7 @@ def finalize_options(self) -> None:
275275 self .distribution .has_ext_modules () or self .distribution .has_c_libraries ()
276276 )
277277
278- if self .py_limited_api and not re .match (
279- PY_LIMITED_API_PATTERN , self .py_limited_api
280- ):
281- raise ValueError (f"py-limited-api must match '{ PY_LIMITED_API_PATTERN } '" )
282-
283- if sysconfig .get_config_var ("Py_GIL_DISABLED" ):
284- SetuptoolsWarning .emit (
285- summary = f"Ignoring `py_limited_api={ self .py_limited_api !r} `." ,
286- details = "`Py_LIMITED_API` is currently incompatible with "
287- f"`Py_GIL_DISABLED` ({ sys .abiflags = !r} )." ,
288- see_url = "https://github.com/python/cpython/issues/111506" ,
289- )
290- self .py_limited_api = False
278+ self ._validate_py_limited_api ()
291279
292280 # Support legacy [wheel] section for setting universal
293281 wheel = self .distribution .get_option_dict ("wheel" )
@@ -301,6 +289,22 @@ def finalize_options(self) -> None:
301289 if self .build_number is not None and not self .build_number [:1 ].isdigit ():
302290 raise ValueError ("Build tag (build-number) must start with a digit." )
303291
292+ def _validate_py_limited_api (self ) -> None :
293+ if not self .py_limited_api :
294+ return
295+
296+ if not re .match (PY_LIMITED_API_PATTERN , self .py_limited_api ):
297+ raise ValueError (f"py-limited-api must match '{ PY_LIMITED_API_PATTERN } '" )
298+
299+ if sysconfig .get_config_var ("Py_GIL_DISABLED" ):
300+ SetuptoolsWarning .emit (
301+ summary = f"Ignoring `py_limited_api={ self .py_limited_api !r} `." ,
302+ details = "`Py_LIMITED_API` is currently incompatible with "
303+ f"`Py_GIL_DISABLED` ({ sys .abiflags = !r} )." ,
304+ see_url = "https://github.com/python/cpython/issues/111506" ,
305+ )
306+ self .py_limited_api = False
307+
304308 @property
305309 def wheel_dist_name (self ) -> str :
306310 """Return distribution full name with - replaced with _"""
0 commit comments