From f0e4efa309f601d4514bb3197ba7c89caa5b72aa Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:22:25 +0900 Subject: [PATCH 1/4] fix(pypi): treat abi3t as a stable ABI tag in whl_target_platforms --- python/private/pypi/whl_target_platforms.bzl | 5 ++++- .../pypi/whl_target_platforms/whl_target_platforms_tests.bzl | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/private/pypi/whl_target_platforms.bzl b/python/private/pypi/whl_target_platforms.bzl index 28547c679c..5a658ad9db 100644 --- a/python/private/pypi/whl_target_platforms.bzl +++ b/python/private/pypi/whl_target_platforms.bzl @@ -64,7 +64,10 @@ def whl_target_platforms(platform_tag, abi_tag = ""): cpus = _cpu_from_tag(platform_tag) abi = None - if abi_tag not in ["", "none", "abi3"]: + + # The stable ABI tags (`abi3` and `abi3t`, see https://peps.python.org/pep-0803/) + # do not identify a single interpreter ABI. + if abi_tag not in ["", "none", "abi3", "abi3t"]: abi = abi_tag # TODO @aignas 2024-05-29: this code is present in many places, I think diff --git a/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl b/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl index 6bec26c10c..fc5cac9221 100644 --- a/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl +++ b/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl @@ -43,7 +43,7 @@ def _test_simple(env): } for give, want in tests.items(): - for abi in ["", "abi3", "none"]: + for abi in ["", "abi3", "abi3t", "none"]: got = whl_target_platforms(give, abi) env.expect.that_collection(got).contains_exactly(want) From 3da53c3aab0bcfaa68a5793d76c0186afa7ffe82 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:22:31 +0900 Subject: [PATCH 2/4] feat(pypi): select abi3t wheels on free-threaded platforms --- python/private/pypi/default_platforms.bzl | 10 +- tests/pypi/extension/extension_tests.bzl | 2 +- tests/pypi/hub_builder/hub_builder_tests.bzl | 2 +- tests/pypi/select_whl/select_whl_tests.bzl | 157 +++++++++++++++++++ 4 files changed, 168 insertions(+), 3 deletions(-) diff --git a/python/private/pypi/default_platforms.bzl b/python/private/pypi/default_platforms.bzl index d3032726e1..0ffd33d07e 100644 --- a/python/private/pypi/default_platforms.bzl +++ b/python/private/pypi/default_platforms.bzl @@ -26,7 +26,15 @@ def _platform( "marker": "python_version >= '3.13'" if freethreaded else marker, "name": name, "os_name": os_name, - "whl_abi_tags": ["cp{major}{minor}t"] if freethreaded else [ + # The free-threaded builds can use the `abi3t` stable ABI wheels, see + # https://peps.python.org/pep-0803/. The python tag of the `abi3t` wheels + # is the minimum supported version, which is handled in the same way as + # for `abi3` when selecting the wheels. The GIL-enabled builds cannot + # use `abi3t` wheels unless they are also tagged with `abi3`, e.g. + # `cp315-abi3.abi3t`. + # + # The last item has the highest priority. + "whl_abi_tags": ["abi3t", "cp{major}{minor}t"] if freethreaded else [ "abi3", "cp{major}{minor}", ], diff --git a/tests/pypi/extension/extension_tests.bzl b/tests/pypi/extension/extension_tests.bzl index b14e6feffb..7ec4439b21 100644 --- a/tests/pypi/extension/extension_tests.bzl +++ b/tests/pypi/extension/extension_tests.bzl @@ -85,7 +85,7 @@ _default_tags_default = [ "@platforms//os:{}".format(os), "@platforms//cpu:{}".format(cpu), ], - whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else ["abi3", "cp{major}{minor}"], + whl_abi_tags = ["abi3t", "cp{major}{minor}t"] if freethreaded else ["abi3", "cp{major}{minor}"], whl_platform_tags = whl_platform_tags, ) for (os, cpu, freethreaded), whl_platform_tags in { diff --git a/tests/pypi/hub_builder/hub_builder_tests.bzl b/tests/pypi/hub_builder/hub_builder_tests.bzl index 073ccc0f58..92d1208644 100644 --- a/tests/pypi/hub_builder/hub_builder_tests.bzl +++ b/tests/pypi/hub_builder/hub_builder_tests.bzl @@ -66,7 +66,7 @@ def hub_builder( "@platforms//os:{}".format(os), "@platforms//cpu:{}".format(cpu), ], - whl_abi_tags = ["cp{major}{minor}t"] if freethreaded else ["abi3", "cp{major}{minor}"], + whl_abi_tags = ["abi3t", "cp{major}{minor}t"] if freethreaded else ["abi3", "cp{major}{minor}"], whl_platform_tags = whl_platform_tags, ) for (os, cpu, freethreaded), whl_platform_tags in { diff --git a/tests/pypi/select_whl/select_whl_tests.bzl b/tests/pypi/select_whl/select_whl_tests.bzl index 8d2170ed7f..c448891b2c 100644 --- a/tests/pypi/select_whl/select_whl_tests.bzl +++ b/tests/pypi/select_whl/select_whl_tests.bzl @@ -2,6 +2,7 @@ load("@rules_testing//lib:test_suite.bzl", "test_suite") load("//python/private:repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "REPO_VERBOSITY_ENV_VAR", "repo_utils") # buildifier: disable=bzl-visibility +load("//python/private/pypi:default_platforms.bzl", "default_platforms") # buildifier: disable=bzl-visibility load("//python/private/pypi:select_whl.bzl", "select_whl") # buildifier: disable=bzl-visibility WHL_LIST = [ @@ -547,6 +548,162 @@ def _test_android(env): _tests.append(_test_android) +def _default_abi_tags(platform, python_version): + major, _, minor = python_version.partition(".") + return ["none"] + [ + tag.format(major = major, minor = minor) + for tag in default_platforms()[platform]["whl_abi_tags"] + ] + +# See https://peps.python.org/pep-0803/ +ABI3T_WHL_LIST = [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-cp315-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-cp315t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-cp316t-manylinux_2_17_x86_64.whl", +] + +def _test_abi3t_freethreaded(env): + got = _select_whl( + whls = [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-cp315-manylinux_2_17_x86_64.whl", + ], + whl_platform_tags = ["any", "manylinux_*_x86_64"], + whl_abi_tags = _default_abi_tags("linux_x86_64_freethreaded", "3.15"), + python_version = "3.15", + limit = 3, + ) + _match( + env, + got, + # The free-threaded builds cannot use `abi3` or `cp315` wheels. + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + ) + +_tests.append(_test_abi3t_freethreaded) + +def _test_abi3t_prefer_version_specific(env): + got = _select_whl( + whls = ABI3T_WHL_LIST, + whl_platform_tags = ["any", "manylinux_*_x86_64"], + whl_abi_tags = _default_abi_tags("linux_x86_64_freethreaded", "3.15"), + python_version = "3.15", + limit = 3, + ) + _match( + env, + got, + # The last item has the most priority + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-cp315t-manylinux_2_17_x86_64.whl", + ) + +_tests.append(_test_abi3t_prefer_version_specific) + +def _test_abi3t_python_tag_is_minimum_version(env): + # The `cp315-abi3t` wheel can be used on 3.15 and above, whilst the + # `cp316-abi3t` wheel cannot be used on 3.15. + for python_version, want in { + "3.14": [ + "pkg-0.0.1-py3-none-any.whl", + ], + "3.15": [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + ], + "3.16": [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", + ], + "3.17": [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", + ], + }.items(): + got = _select_whl( + whls = [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", + ], + whl_platform_tags = ["any", "manylinux_*_x86_64"], + whl_abi_tags = _default_abi_tags("linux_x86_64_freethreaded", python_version), + python_version = python_version, + limit = 3, + ) + _match(env, got, *want) + +_tests.append(_test_abi3t_python_tag_is_minimum_version) + +def _test_abi3t_newer_cpxt_preferred(env): + got = _select_whl( + whls = ABI3T_WHL_LIST, + whl_platform_tags = ["any", "manylinux_*_x86_64"], + whl_abi_tags = _default_abi_tags("linux_x86_64_freethreaded", "3.16"), + python_version = "3.16", + limit = 4, + ) + _match( + env, + got, + # The last item has the most priority + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-cp316t-manylinux_2_17_x86_64.whl", + ) + +_tests.append(_test_abi3t_newer_cpxt_preferred) + +def _test_abi3t_not_selected_on_gil_builds(env): + got = _select_whl( + whls = [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-cp315t-manylinux_2_17_x86_64.whl", + ], + whl_platform_tags = ["any", "manylinux_*_x86_64"], + whl_abi_tags = _default_abi_tags("linux_x86_64", "3.15"), + python_version = "3.15", + limit = 3, + ) + _match( + env, + got, + # The GIL-enabled builds cannot use `abi3t` only wheels. + "pkg-0.0.1-py3-none-any.whl", + ) + +_tests.append(_test_abi3t_not_selected_on_gil_builds) + +def _test_abi3_abi3t_compressed_tag(env): + whls = [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3.abi3t-manylinux_2_17_x86_64.whl", + ] + for platform in ["linux_x86_64", "linux_x86_64_freethreaded"]: + got = _select_whl( + whls = whls, + whl_platform_tags = ["any", "manylinux_*_x86_64"], + whl_abi_tags = _default_abi_tags(platform, "3.15"), + python_version = "3.15", + ) + + # The wheels compatible with both ABIs can be used on both builds. + _match(env, [got], "pkg-0.0.1-cp315-abi3.abi3t-manylinux_2_17_x86_64.whl") + +_tests.append(_test_abi3_abi3t_compressed_tag) + def select_whl_test_suite(name): """Create the test suite. From 9e69cab4a927928c034dcbe5646c4b8388053ec4 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:22:34 +0900 Subject: [PATCH 3/4] docs(pypi): document abi3t wheel selection --- news/abi3t-whl-selection.added.md | 4 ++++ python/private/pypi/extension.bzl | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 news/abi3t-whl-selection.added.md diff --git a/news/abi3t-whl-selection.added.md b/news/abi3t-whl-selection.added.md new file mode 100644 index 0000000000..2f76e1cb10 --- /dev/null +++ b/news/abi3t-whl-selection.added.md @@ -0,0 +1,4 @@ +(pypi) The default `_freethreaded` {obj}`pip.default` platforms now select the +`abi3t` wheels that use the stable ABI for the free-threaded builds as specified +in [PEP 803](https://peps.python.org/pep-0803/). The version-specific `cp3xt` +wheels are still preferred over `abi3t` wheels. diff --git a/python/private/pypi/extension.bzl b/python/private/pypi/extension.bzl index c3c613537d..1734bbcc66 100644 --- a/python/private/pypi/extension.bzl +++ b/python/private/pypi/extension.bzl @@ -685,6 +685,17 @@ parameters like `{major}` and `{minor}` which will be replaced with python versi `cp{major}{minor}` will result in `cp313` given the full python version is `3.13.5`. Will always include `"none"` even if it is not specified. +The python tag of the wheels using the stable ABI (`abi3` and `abi3t`) is treated as the +minimum supported Python version, e.g. a `cp315-abi3t` wheel is selected for Python `3.15` +and above. + +The default platforms use the following values: +* `["abi3", "cp{major}{minor}"]` for the GIL-enabled builds. +* `["abi3t", "cp{major}{minor}t"]` for the free-threaded builds, where `abi3t` is the + stable ABI for the free-threaded builds as specified in + [PEP 803](https://peps.python.org/pep-0803/). The GIL-enabled builds only select `abi3t` + wheels if they are also tagged as `abi3` (e.g. `cp315-abi3.abi3t`). + :::{note} We select a single wheel and the last match will take precedence. ::: @@ -692,6 +703,10 @@ We select a single wheel and the last match will take precedence. :::{seealso} See official [docs](https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/#abi-tag) for more information. ::: + +:::{versionchanged} VERSION_NEXT_FEATURE +The default free-threaded platforms select the `abi3t` wheels. +::: """, ), "whl_platform_tags": attr.string_list( From 33205b2ace061d088159a64364507b65af18536a Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sat, 14 Nov 2026 16:22:24 -0800 Subject: [PATCH 4/4] refactor(pypi): handle abi3.abi3t tags in whl_target_platforms PEP 803 wheels compatible with both GIL-enabled and free-threaded stable ABIs use the compressed `abi3.abi3t` tag, which `whl_target_platforms` previously treated as a single interpreter ABI instead of `None`. Split `abi_tag` on dots when checking for stable ABI tags, reuse `default_platforms()` in test helpers instead of duplicating inline ABI ternaries, and align line wrapping and constant ordering with style conventions. --- python/private/pypi/default_platforms.bzl | 26 +++++----- python/private/pypi/extension.bzl | 15 +++--- python/private/pypi/whl_target_platforms.bzl | 11 +++-- tests/pypi/extension/extension_tests.bzl | 6 ++- tests/pypi/hub_builder/hub_builder_tests.bzl | 7 ++- tests/pypi/select_whl/select_whl_tests.bzl | 47 +++++++++++-------- .../whl_target_platforms_tests.bzl | 2 +- 7 files changed, 68 insertions(+), 46 deletions(-) diff --git a/python/private/pypi/default_platforms.bzl b/python/private/pypi/default_platforms.bzl index 0ffd33d07e..8d3b119aa8 100644 --- a/python/private/pypi/default_platforms.bzl +++ b/python/private/pypi/default_platforms.bzl @@ -12,6 +12,19 @@ def _platform( os_constraint = None, config_settings = [], marker = ""): + # The free-threaded builds can use the `abi3t` stable ABI wheels, see + # https://peps.python.org/pep-0803/. The python tag of the `abi3t` + # wheels is the minimum supported version, which is handled in the same + # way as for `abi3` when selecting the wheels. The GIL-enabled builds + # cannot use `abi3t` wheels unless they are also tagged with `abi3`, + # e.g. `cp315-abi3.abi3t`. + # + # The last item has the highest priority. + if freethreaded: + whl_abi_tags = ["abi3t", "cp{major}{minor}t"] + else: + whl_abi_tags = ["abi3", "cp{major}{minor}"] + return { "arch_name": arch_name, "config_settings": [ @@ -26,18 +39,7 @@ def _platform( "marker": "python_version >= '3.13'" if freethreaded else marker, "name": name, "os_name": os_name, - # The free-threaded builds can use the `abi3t` stable ABI wheels, see - # https://peps.python.org/pep-0803/. The python tag of the `abi3t` wheels - # is the minimum supported version, which is handled in the same way as - # for `abi3` when selecting the wheels. The GIL-enabled builds cannot - # use `abi3t` wheels unless they are also tagged with `abi3`, e.g. - # `cp315-abi3.abi3t`. - # - # The last item has the highest priority. - "whl_abi_tags": ["abi3t", "cp{major}{minor}t"] if freethreaded else [ - "abi3", - "cp{major}{minor}", - ], + "whl_abi_tags": whl_abi_tags, "whl_platform_tags": whl_platform_tags, } diff --git a/python/private/pypi/extension.bzl b/python/private/pypi/extension.bzl index 1734bbcc66..b31fb661f5 100644 --- a/python/private/pypi/extension.bzl +++ b/python/private/pypi/extension.bzl @@ -685,16 +685,17 @@ parameters like `{major}` and `{minor}` which will be replaced with python versi `cp{major}{minor}` will result in `cp313` given the full python version is `3.13.5`. Will always include `"none"` even if it is not specified. -The python tag of the wheels using the stable ABI (`abi3` and `abi3t`) is treated as the -minimum supported Python version, e.g. a `cp315-abi3t` wheel is selected for Python `3.15` -and above. +The python tag of the wheels using the stable ABI (`abi3` and `abi3t`) is +treated as the minimum supported Python version, e.g. a `cp315-abi3t` wheel is +selected for Python `3.15` and above. The default platforms use the following values: * `["abi3", "cp{major}{minor}"]` for the GIL-enabled builds. -* `["abi3t", "cp{major}{minor}t"]` for the free-threaded builds, where `abi3t` is the - stable ABI for the free-threaded builds as specified in - [PEP 803](https://peps.python.org/pep-0803/). The GIL-enabled builds only select `abi3t` - wheels if they are also tagged as `abi3` (e.g. `cp315-abi3.abi3t`). +* `["abi3t", "cp{major}{minor}t"]` for the free-threaded builds, where `abi3t` + is the stable ABI for the free-threaded builds as specified in + [PEP 803](https://peps.python.org/pep-0803/). The GIL-enabled builds only + select `abi3t` wheels if they are also tagged as `abi3` (e.g. + `cp315-abi3.abi3t`). :::{note} We select a single wheel and the last match will take precedence. diff --git a/python/private/pypi/whl_target_platforms.bzl b/python/private/pypi/whl_target_platforms.bzl index 5a658ad9db..b48b3bb8fe 100644 --- a/python/private/pypi/whl_target_platforms.bzl +++ b/python/private/pypi/whl_target_platforms.bzl @@ -65,10 +65,13 @@ def whl_target_platforms(platform_tag, abi_tag = ""): abi = None - # The stable ABI tags (`abi3` and `abi3t`, see https://peps.python.org/pep-0803/) - # do not identify a single interpreter ABI. - if abi_tag not in ["", "none", "abi3", "abi3t"]: - abi = abi_tag + # Stable ABI tags (`abi3`, `abi3t`, and `abi3.abi3t`; see + # https://peps.python.org/pep-0803/) do not identify a single + # interpreter ABI. + for tag in abi_tag.split("."): + if tag not in ["", "none", "abi3", "abi3t"]: + abi = abi_tag + break # TODO @aignas 2024-05-29: this code is present in many places, I think _, _, tail = platform_tag.partition("_") diff --git a/tests/pypi/extension/extension_tests.bzl b/tests/pypi/extension/extension_tests.bzl index 7ec4439b21..91bf3c76d1 100644 --- a/tests/pypi/extension/extension_tests.bzl +++ b/tests/pypi/extension/extension_tests.bzl @@ -75,6 +75,10 @@ def _default( whl_platform_tags = whl_platform_tags or [], ) +def _default_whl_abi_tags(os, cpu, freethreaded): + platform = "{}_{}{}".format(os, cpu, freethreaded) + return default_platforms()[platform]["whl_abi_tags"] + # The default value for the default platforms tags use in `_mod`. _default_tags_default = [ _default( @@ -85,7 +89,7 @@ _default_tags_default = [ "@platforms//os:{}".format(os), "@platforms//cpu:{}".format(cpu), ], - whl_abi_tags = ["abi3t", "cp{major}{minor}t"] if freethreaded else ["abi3", "cp{major}{minor}"], + whl_abi_tags = _default_whl_abi_tags(os, cpu, freethreaded), whl_platform_tags = whl_platform_tags, ) for (os, cpu, freethreaded), whl_platform_tags in { diff --git a/tests/pypi/hub_builder/hub_builder_tests.bzl b/tests/pypi/hub_builder/hub_builder_tests.bzl index 92d1208644..d66039a08d 100644 --- a/tests/pypi/hub_builder/hub_builder_tests.bzl +++ b/tests/pypi/hub_builder/hub_builder_tests.bzl @@ -17,6 +17,7 @@ load("@rules_testing//lib:test_suite.bzl", "test_suite") load("@rules_testing//lib:truth.bzl", "subjects") load("//python/private:repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "REPO_VERBOSITY_ENV_VAR", "repo_utils") # buildifier: disable=bzl-visibility +load("//python/private/pypi:default_platforms.bzl", "default_platforms") # buildifier: disable=bzl-visibility load("//python/private/pypi:hub_builder.bzl", _hub_builder = "hub_builder") # buildifier: disable=bzl-visibility load("//python/private/pypi:parse_simpleapi_html.bzl", "parse_simpleapi_html") # buildifier: disable=bzl-visibility load("//python/private/pypi:platform.bzl", _plat = "platform") # buildifier: disable=bzl-visibility @@ -40,6 +41,10 @@ simple==0.0.1 \ }, ) +def _default_whl_abi_tags(os, cpu, freethreaded): + platform = "{}_{}{}".format(os, cpu, freethreaded) + return default_platforms()[platform]["whl_abi_tags"] + def hub_builder( env, enable_pipstar_extract = True, @@ -66,7 +71,7 @@ def hub_builder( "@platforms//os:{}".format(os), "@platforms//cpu:{}".format(cpu), ], - whl_abi_tags = ["abi3t", "cp{major}{minor}t"] if freethreaded else ["abi3", "cp{major}{minor}"], + whl_abi_tags = _default_whl_abi_tags(os, cpu, freethreaded), whl_platform_tags = whl_platform_tags, ) for (os, cpu, freethreaded), whl_platform_tags in { diff --git a/tests/pypi/select_whl/select_whl_tests.bzl b/tests/pypi/select_whl/select_whl_tests.bzl index c448891b2c..422c93c4f4 100644 --- a/tests/pypi/select_whl/select_whl_tests.bzl +++ b/tests/pypi/select_whl/select_whl_tests.bzl @@ -62,6 +62,17 @@ WHL_LIST = [ "pkg-0.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", ] +# See https://peps.python.org/pep-0803/ +ABI3T_WHL_LIST = [ + "pkg-0.0.1-py3-none-any.whl", + "pkg-0.0.1-cp315-abi3-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-cp315-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp315-cp315t-manylinux_2_17_x86_64.whl", + "pkg-0.0.1-cp316-cp316t-manylinux_2_17_x86_64.whl", +] + def _match(env, got, *want_filenames): if not want_filenames: env.expect.that_collection(got).has_size(len(want_filenames)) @@ -93,6 +104,13 @@ def _select_whl(whls, debug = False, **kwargs): **kwargs ) +def _default_abi_tags(platform, python_version): + major, _, minor = python_version.partition(".") + return ["none"] + [ + tag.format(major = major, minor = minor) + for tag in default_platforms()[platform]["whl_abi_tags"] + ] + _tests = [] def _test_not_select_py2(env): @@ -548,24 +566,6 @@ def _test_android(env): _tests.append(_test_android) -def _default_abi_tags(platform, python_version): - major, _, minor = python_version.partition(".") - return ["none"] + [ - tag.format(major = major, minor = minor) - for tag in default_platforms()[platform]["whl_abi_tags"] - ] - -# See https://peps.python.org/pep-0803/ -ABI3T_WHL_LIST = [ - "pkg-0.0.1-py3-none-any.whl", - "pkg-0.0.1-cp315-abi3-manylinux_2_17_x86_64.whl", - "pkg-0.0.1-cp315-abi3t-manylinux_2_17_x86_64.whl", - "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", - "pkg-0.0.1-cp315-cp315-manylinux_2_17_x86_64.whl", - "pkg-0.0.1-cp315-cp315t-manylinux_2_17_x86_64.whl", - "pkg-0.0.1-cp316-cp316t-manylinux_2_17_x86_64.whl", -] - def _test_abi3t_freethreaded(env): got = _select_whl( whls = [ @@ -637,7 +637,10 @@ def _test_abi3t_python_tag_is_minimum_version(env): "pkg-0.0.1-cp316-abi3t-manylinux_2_17_x86_64.whl", ], whl_platform_tags = ["any", "manylinux_*_x86_64"], - whl_abi_tags = _default_abi_tags("linux_x86_64_freethreaded", python_version), + whl_abi_tags = _default_abi_tags( + "linux_x86_64_freethreaded", + python_version, + ), python_version = python_version, limit = 3, ) @@ -700,7 +703,11 @@ def _test_abi3_abi3t_compressed_tag(env): ) # The wheels compatible with both ABIs can be used on both builds. - _match(env, [got], "pkg-0.0.1-cp315-abi3.abi3t-manylinux_2_17_x86_64.whl") + _match( + env, + [got], + "pkg-0.0.1-cp315-abi3.abi3t-manylinux_2_17_x86_64.whl", + ) _tests.append(_test_abi3_abi3t_compressed_tag) diff --git a/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl b/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl index fc5cac9221..7c0d0ad8d5 100644 --- a/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl +++ b/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl @@ -43,7 +43,7 @@ def _test_simple(env): } for give, want in tests.items(): - for abi in ["", "abi3", "abi3t", "none"]: + for abi in ["", "abi3", "abi3t", "abi3.abi3t", "none"]: got = whl_target_platforms(give, abi) env.expect.that_collection(got).contains_exactly(want)