Skip to content

Commit

Permalink
Prevent abi3 from being used with no-GIL interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Jun 17, 2024
1 parent d1bea1b commit e455314
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions setuptools/command/bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,7 @@ def get_tag(self) -> tuple[str, str, str]:
impl = self.python_tag
tag = (impl, "none", plat_name)
else:
impl_name = tags.interpreter_name()
impl_ver = tags.interpreter_version()
impl = impl_name + impl_ver
# We don't work on CPython 3.1, 3.0.
if self.py_limited_api and (impl_name + impl_ver).startswith("cp3"):
impl = self.py_limited_api
abi_tag = "abi3"
else:
abi_tag = str(get_abi_tag()).lower()
tag = (impl, abi_tag, plat_name)
tag = self._get_tag_impure(plat_name)
# issue gh-374: allow overriding plat_name
supported_tags = [
(t.interpreter, t.abi, plat_name) for t in tags.sys_tags()
Expand All @@ -363,6 +354,24 @@ def get_tag(self) -> tuple[str, str, str]:
), f"would build wheel with unsupported tag {tag}"
return tag

def _get_tag_impure(self, plat_name: str) -> tuple[str, str, str]:
impl_name = tags.interpreter_name()
impl_ver = tags.interpreter_version()
impl = impl_name + impl_ver
# We don't work on CPython 3.1, 3.0.
if self.py_limited_api and impl.startswith("cp3"):
if "t" in impl_ver:
log.warn(
f"Ignoring abi3 implied by py_limited_api={self.py_limited_api!r} - "
f"incompatible with {impl!r} interpreter."
)
else:
abi_tag = "abi3"
impl = self.py_limited_api
else:
abi_tag = str(get_abi_tag()).lower()
return (impl, abi_tag, plat_name)

def run(self):
build_scripts = self.reinitialize_command("build_scripts")
build_scripts.executable = "python"
Expand Down

0 comments on commit e455314

Please sign in to comment.