diff --git a/packaging/tags.py b/packaging/tags.py index 034c16bb..ae0b4e48 100644 --- a/packaging/tags.py +++ b/packaging/tags.py @@ -240,7 +240,11 @@ def _generic_abi() -> List[str]: ext_suffix = _get_config_var("EXT_SUFFIX", warn=True) if not isinstance(ext_suffix, str) or ext_suffix[0] != ".": raise SystemError("invalid sysconfig.get_config_var('EXT_SUFFIX')") - _, soabi, ext = ext_suffix.split(".") + parts = ext_suffix.split(".") + if len(parts) < 3: + # CPython3.7 and earlier uses ".pyd" on windows + return _cpython_abis(sys.version_info[:2]) + soabi = parts[1] if soabi.startswith("cpython"): abi = "cp" + soabi.split("-")[1] elif soabi.startswith("pypy"): diff --git a/tests/test_tags.py b/tests/test_tags.py index dd2a2d14..d2fa9222 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -875,6 +875,14 @@ def test__generic_abi_linux_pypy(self, monkeypatch): monkeypatch.setattr(tags, "interpreter_name", lambda: "pp") assert tags._generic_abi() == ["pypy39_pp73"] + def test__generic_abi_old_windows(self, monkeypatch): + config = { + "EXT_SUFFIX": ".pyd", + "Py_DEBUG": 0, + } + monkeypatch.setattr(sysconfig, "get_config_var", config.__getitem__) + assert tags._generic_abi() == tags._cpython_abis(sys.version_info[:2]) + def test_generic_platforms(self): platform = sysconfig.get_platform().replace("-", "_") platform = platform.replace(".", "_")