Skip to content

Commit

Permalink
fix _generic_tag for CPython+windows, add comment about pyston
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Dec 10, 2022
1 parent 682d500 commit 6a37a6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 []
Expand Down
6 changes: 6 additions & 0 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(".", "_")
Expand Down

0 comments on commit 6a37a6e

Please sign in to comment.