Skip to content

Commit 747e1f6

Browse files
authored
Fixed PyPy SOABI parsing (#484)
1 parent 7627548 commit 747e1f6

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

docs/news.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Release Notes
1313
- Fixed ``ValueError: ZIP does not support timestamps before 1980`` when using
1414
``SOURCE_DATE_EPOCH=0`` or when on-disk timestamps are earlier than 1980-01-01. Such
1515
timestamps are now changed to the minimum value before packaging.
16+
- The future-proof fix in 0.36.0 for converting PyPy's SOABI into a abi tag was
17+
faulty. Fixed so that future changes in the SOABI will not change the tag.
1618

1719
**0.37.1 (2021-12-22)**
1820

src/wheel/bdist_wheel.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from email.generator import BytesGenerator, Generator
1818
from io import BytesIO
1919
from shutil import rmtree
20-
from sysconfig import get_config_var
2120
from zipfile import ZIP_DEFLATED, ZIP_STORED
2221

2322
import pkg_resources
@@ -55,7 +54,7 @@ def get_platform(archive_root):
5554
def get_flag(var, fallback, expected=True, warn=True):
5655
"""Use a fallback value for determining SOABI flags if the needed config
5756
var is unset or unavailable."""
58-
val = get_config_var(var)
57+
val = sysconfig.get_config_var(var)
5958
if val is None:
6059
if warn:
6160
warnings.warn(
@@ -69,8 +68,8 @@ def get_flag(var, fallback, expected=True, warn=True):
6968

7069

7170
def get_abi_tag():
72-
"""Return the ABI tag based on SOABI (if available) or emulate SOABI (PyPy)."""
73-
soabi = get_config_var("SOABI")
71+
"""Return the ABI tag based on SOABI (if available) or emulate SOABI (PyPy2)."""
72+
soabi = sysconfig.get_config_var("SOABI")
7473
impl = tags.interpreter_name()
7574
if not soabi and impl in ("cp", "pp") and hasattr(sys, "maxunicode"):
7675
d = ""
@@ -87,9 +86,9 @@ def get_abi_tag():
8786
m = "m"
8887

8988
abi = f"{impl}{tags.interpreter_version()}{d}{m}{u}"
90-
elif soabi and soabi.startswith("cpython-"):
89+
elif soabi and impl == "cp":
9190
abi = "cp" + soabi.split("-")[1]
92-
elif soabi and soabi.startswith("pypy-"):
91+
elif soabi and impl == "pp":
9392
# we want something like pypy36-pp73
9493
abi = "-".join(soabi.split("-")[:2])
9594
abi = abi.replace(".", "_").replace("-", "_")

tests/test_bdist_wheel.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import stat
66
import subprocess
77
import sys
8+
import sysconfig
89
from zipfile import ZipFile
910

1011
import pytest
1112

12-
from wheel.bdist_wheel import bdist_wheel
13+
from wheel.bdist_wheel import bdist_wheel, get_abi_tag
14+
from wheel.vendored.packaging import tags
1315
from wheel.wheelfile import WheelFile
1416

1517
DEFAULT_FILES = {
@@ -218,3 +220,15 @@ def test_unix_epoch_timestamps(dummy_dist, monkeypatch, tmpdir):
218220
"--build-number=2",
219221
]
220222
)
223+
224+
225+
def test_get_abi_tag_old(monkeypatch):
226+
monkeypatch.setattr(tags, "interpreter_name", lambda: "pp")
227+
monkeypatch.setattr(sysconfig, "get_config_var", lambda x: "pypy36-pp73")
228+
assert get_abi_tag() == "pypy36_pp73"
229+
230+
231+
def test_get_abi_tag_new(monkeypatch):
232+
monkeypatch.setattr(sysconfig, "get_config_var", lambda x: "pypy37-pp73-darwin")
233+
monkeypatch.setattr(tags, "interpreter_name", lambda: "pp")
234+
assert get_abi_tag() == "pypy37_pp73"

0 commit comments

Comments
 (0)