Skip to content

Commit

Permalink
fix for 'cpython<=3.7' on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Nov 10, 2022
1 parent a3d7675 commit e6cd1cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(".", "_")
Expand Down

0 comments on commit e6cd1cc

Please sign in to comment.