diff --git a/docs/news.rst b/docs/news.rst index 8c4ce091..98eb19d2 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -13,6 +13,8 @@ Release Notes - Fixed ``ValueError: ZIP does not support timestamps before 1980`` when using ``SOURCE_DATE_EPOCH=0`` or when on-disk timestamps are earlier than 1980-01-01. Such timestamps are now changed to the minimum value before packaging. +- The future-proof fix in 0.36.0 for converting PyPy's SOABI into a abi tag was + faulty. Fixed so that future changes in the SOABI will not change the tag. **0.37.1 (2021-12-22)** diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py index 7cbd1402..3a82caa8 100644 --- a/src/wheel/bdist_wheel.py +++ b/src/wheel/bdist_wheel.py @@ -17,7 +17,6 @@ from email.generator import BytesGenerator, Generator from io import BytesIO from shutil import rmtree -from sysconfig import get_config_var from zipfile import ZIP_DEFLATED, ZIP_STORED import pkg_resources @@ -55,7 +54,7 @@ def get_platform(archive_root): def get_flag(var, fallback, expected=True, warn=True): """Use a fallback value for determining SOABI flags if the needed config var is unset or unavailable.""" - val = get_config_var(var) + val = sysconfig.get_config_var(var) if val is None: if warn: warnings.warn( @@ -69,8 +68,8 @@ def get_flag(var, fallback, expected=True, warn=True): def get_abi_tag(): - """Return the ABI tag based on SOABI (if available) or emulate SOABI (PyPy).""" - soabi = get_config_var("SOABI") + """Return the ABI tag based on SOABI (if available) or emulate SOABI (PyPy2).""" + soabi = sysconfig.get_config_var("SOABI") impl = tags.interpreter_name() if not soabi and impl in ("cp", "pp") and hasattr(sys, "maxunicode"): d = "" @@ -87,9 +86,9 @@ def get_abi_tag(): m = "m" abi = f"{impl}{tags.interpreter_version()}{d}{m}{u}" - elif soabi and soabi.startswith("cpython-"): + elif soabi and impl == "cp": abi = "cp" + soabi.split("-")[1] - elif soabi and soabi.startswith("pypy-"): + elif soabi and impl == "pp": # we want something like pypy36-pp73 abi = "-".join(soabi.split("-")[:2]) abi = abi.replace(".", "_").replace("-", "_") diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py index 2a4d777a..d54cee77 100644 --- a/tests/test_bdist_wheel.py +++ b/tests/test_bdist_wheel.py @@ -5,11 +5,13 @@ import stat import subprocess import sys +import sysconfig from zipfile import ZipFile import pytest -from wheel.bdist_wheel import bdist_wheel +from wheel.bdist_wheel import bdist_wheel, get_abi_tag +from wheel.vendored.packaging import tags from wheel.wheelfile import WheelFile DEFAULT_FILES = { @@ -218,3 +220,15 @@ def test_unix_epoch_timestamps(dummy_dist, monkeypatch, tmpdir): "--build-number=2", ] ) + + +def test_get_abi_tag_old(monkeypatch): + monkeypatch.setattr(tags, "interpreter_name", lambda: "pp") + monkeypatch.setattr(sysconfig, "get_config_var", lambda x: "pypy36-pp73") + assert get_abi_tag() == "pypy36_pp73" + + +def test_get_abi_tag_new(monkeypatch): + monkeypatch.setattr(sysconfig, "get_config_var", lambda x: "pypy37-pp73-darwin") + monkeypatch.setattr(tags, "interpreter_name", lambda: "pp") + assert get_abi_tag() == "pypy37_pp73"