diff --git a/src/packaging/tags.py b/src/packaging/tags.py index ae0b4e48..af756273 100644 --- a/src/packaging/tags.py +++ b/src/packaging/tags.py @@ -233,6 +233,7 @@ def _generic_abi() -> List[str]: # - linux: '.cpython-310-x86_64-linux-gnu.so' => cp310 # - mac: '.cpython-310-darwin.so' => cp310 # - win: '.cp310-win_amd64.pyd' => cp310 + # - win: '.pyd' => cp37 (uses _cpython_abis()) # - pypy: '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38_pp73 # - graalpy: '.graalpy-38-native-x86_64-darwin.dylib' # => graalpy_38_native @@ -246,12 +247,17 @@ def _generic_abi() -> List[str]: return _cpython_abis(sys.version_info[:2]) soabi = parts[1] if soabi.startswith("cpython"): + # non-windows abi = "cp" + soabi.split("-")[1] + elif soabi.startswith("cp"): + # windows + abi = soabi.split("-")[0] elif soabi.startswith("pypy"): abi = "-".join(soabi.split("-")[:2]) elif soabi.startswith("graalpy"): abi = "-".join(soabi.split("-")[:3]) elif soabi: + # pyston, ironpython, others? abi = soabi else: return [] diff --git a/tests/test_tags.py b/tests/test_tags.py index 6f3281c2..244e11df 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -884,6 +884,12 @@ def test__generic_abi_old_windows(self, monkeypatch): monkeypatch.setattr(sysconfig, "get_config_var", config.__getitem__) assert tags._generic_abi() == tags._cpython_abis(sys.version_info[:2]) + @pytest.mark.skipif(sys.implementation.name != "cpython", reason="CPython-only") + def test__generic_abi_windows(self): + """Test that the two methods of finding the abi tag agree + """ + assert tags._generic_abi() == tags._cpython_abis(sys.version_info[:2]) + def test_generic_platforms(self): platform = sysconfig.get_platform().replace("-", "_") platform = platform.replace(".", "_")