test(pypi): select platform specific wheels with target_platforms = ["*"]
diff --git a/tests/pypi/hub_builder/hub_builder_tests.bzl b/tests/pypi/hub_builder/hub_builder_tests.bzl index 0a5c319..c6c4f66 100644 --- a/tests/pypi/hub_builder/hub_builder_tests.bzl +++ b/tests/pypi/hub_builder/hub_builder_tests.bzl
@@ -216,6 +216,80 @@ _tests.append(_test_target_platforms_all) +def _test_target_platforms_all_platform_wheels(env): + builder = hub_builder(env) + builder.pip_parse( + _mock_mctx( + os_name = "osx", + arch_name = "aarch64", + mock_files = { + "uv.lock": json.encode({"package": [ + { + "name": "plat", + "source": {"registry": "https://pypi.org/simple"}, + "version": "0.0.1", + "wheels": [ + {"hash": "sha256:deadb001", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-cp315-cp315-manylinux_2_17_x86_64.whl"}, + {"hash": "sha256:deadb002", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-cp315-cp315t-manylinux_2_17_x86_64.whl"}, + {"hash": "sha256:deadb003", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-cp315-cp315-manylinux_2_17_aarch64.whl"}, + {"hash": "sha256:deadb004", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-cp315-cp315-macosx_11_0_arm64.whl"}, + {"hash": "sha256:deadb005", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-cp315-cp315-win_arm64.whl"}, + {"hash": "sha256:deadb006", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-py3-none-any.whl"}, + ], + }, + ]}), + }, + ), + _parse( + hub_name = "pypi", + python_version = "3.15", + requirements_lock = None, + target_platforms = ["*"], + uv_lock = "uv.lock", + ), + ) + pypi = builder.build() + + pypi.exposed_packages().contains_exactly(["plat"]) + + # Each of the platforms selects its own platform specific wheel. + pypi.whl_map().contains_exactly({ + "plat": { + "pypi_315_plat_cp315_cp315_macosx_11_0_arm64_deadb004": [ + whl_config_setting( + target_platforms = ("cp315_osx_aarch64",), + version = "3.15", + ), + ], + "pypi_315_plat_cp315_cp315_manylinux_2_17_aarch64_deadb003": [ + whl_config_setting( + target_platforms = ("cp315_linux_aarch64",), + version = "3.15", + ), + ], + "pypi_315_plat_cp315_cp315_manylinux_2_17_x86_64_deadb001": [ + whl_config_setting( + target_platforms = ("cp315_linux_x86_64",), + version = "3.15", + ), + ], + "pypi_315_plat_cp315_cp315_win_arm64_deadb005": [ + whl_config_setting( + target_platforms = ("cp315_windows_aarch64",), + version = "3.15", + ), + ], + "pypi_315_plat_cp315_cp315t_manylinux_2_17_x86_64_deadb002": [ + whl_config_setting( + target_platforms = ("cp315_linux_x86_64_freethreaded",), + version = "3.15", + ), + ], + }, + }) + +_tests.append(_test_target_platforms_all_platform_wheels) + def _test_simple_multiple_requirements(env): sub_tests = { ("osx", "aarch64"): "simple==0.0.2 --hash=sha256:deadb00f",