Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent abi3 from being used with no-GIL interpreter #4424

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions newsfragments/4420.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Raises an exception when ``py_limited_api`` is used in a build with
``Py_GIL_DISABLED``. This is currently not supported (python/cpython#111506).
20 changes: 16 additions & 4 deletions setuptools/command/bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,7 @@ def finalize_options(self) -> None:
self.distribution.has_ext_modules() or self.distribution.has_c_libraries()
)

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

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

def _validate_py_limited_api(self) -> None:
if not self.py_limited_api:
return

if not re.match(PY_LIMITED_API_PATTERN, self.py_limited_api):
raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'")

if sysconfig.get_config_var("Py_GIL_DISABLED"):
raise ValueError(
f"`py_limited_api={self.py_limited_api!r}` not supported. "
"`Py_LIMITED_API` is currently incompatible with "
f"`Py_GIL_DISABLED` ({sys.abiflags=!r}). "
"See https://github.com/python/cpython/issues/111506."
)
Comment on lines +299 to +304
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaraco do you agree with this approach?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. I don't have more than a superficial understanding of the concern. For example, it's unclear to me if this limitation is temporary and if so, under what conditions could the restriction be lifted. I hope in the future some people will bring more insight and help provide more robust support for the various combinations (if feasible).


@property
def wheel_dist_name(self) -> str:
"""Return distribution full name with - replaced with _"""
Expand Down
Loading