From 5813844d4fa8cb2ff8dd4fbc99984cd5cc80bc8d Mon Sep 17 00:00:00 2001 From: Thimo Date: Mon, 2 May 2022 22:15:42 +0200 Subject: [PATCH 1/4] Adding universal "cpxx-none-any" tag See https://github.com/pypa/packaging/issues/511 and https://github.com/pypa/pip/issues/10923 --- packaging/tags.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packaging/tags.py b/packaging/tags.py index 744cf2cb..2838e80b 100644 --- a/packaging/tags.py +++ b/packaging/tags.py @@ -482,6 +482,9 @@ def sys_tags(*, warn: bool = False) -> Iterator[Tag]: yield from generic_tags() if interp_name == "pp": - yield from compatible_tags(interpreter="pp3") + interp = "pp3" + elif interp_name == "cp": + interp = "cp" + interpreter_version(warn=warn) else: - yield from compatible_tags() + interp = None + yield from compatible_tags(interpreter=interp) From 03dd8b3e29a6dc71ce28f3bd6a43e9d313630184 Mon Sep 17 00:00:00 2001 From: Thimo Date: Tue, 3 May 2022 13:16:04 +0200 Subject: [PATCH 2/4] Added test --- tests/test_tags.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_tags.py b/tests/test_tags.py index 446dee4e..e72c8e7a 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -1189,3 +1189,15 @@ def test_pypy_first_none_any_tag(self, monkeypatch): break assert tag == tags.Tag("pp3", "none", "any") + + def test_cpython_first_none_any_tag(self, monkeypatch): + # When building the complete list of cpython tags, make sure the first + # -none-any one is cpxx-none-any + monkeypatch.setattr(tags, "interpreter_name", lambda: "cp") + + for tag in tags.sys_tags(): + if tag.abi == "none" and tag.platform == "any": + break + + interpreter = "cp" + tags._version_nodot(sys.version_info[:2]) + assert tag == tags.Tag(interpreter, "none", "any") From b8832405433eb05065a6509eb297c80ba4c41b5f Mon Sep 17 00:00:00 2001 From: Thimo Date: Tue, 3 May 2022 22:20:47 +0200 Subject: [PATCH 3/4] Removed trailing whitespace --- tests/test_tags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_tags.py b/tests/test_tags.py index e72c8e7a..e9ca76c6 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -1194,10 +1194,10 @@ def test_cpython_first_none_any_tag(self, monkeypatch): # When building the complete list of cpython tags, make sure the first # -none-any one is cpxx-none-any monkeypatch.setattr(tags, "interpreter_name", lambda: "cp") - + for tag in tags.sys_tags(): if tag.abi == "none" and tag.platform == "any": break - + interpreter = "cp" + tags._version_nodot(sys.version_info[:2]) assert tag == tags.Tag(interpreter, "none", "any") From 46364f53ce6dc93549b34a9cbea5177752321ccb Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 19 Aug 2022 15:03:08 -0700 Subject: [PATCH 4/4] Apply suggestions from code review --- tests/test_tags.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_tags.py b/tests/test_tags.py index d4a7006a..39515e8d 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -1232,9 +1232,10 @@ def test_cpython_first_none_any_tag(self, monkeypatch): # -none-any one is cpxx-none-any monkeypatch.setattr(tags, "interpreter_name", lambda: "cp") + # Find the first tag that is ABI- and platform-agnostic. for tag in tags.sys_tags(): if tag.abi == "none" and tag.platform == "any": break - interpreter = "cp" + tags._version_nodot(sys.version_info[:2]) + interpreter = f"cp{tags.interpreter_version()}" assert tag == tags.Tag(interpreter, "none", "any")