@@ -1064,6 +1064,94 @@ optimum[onnxruntime-gpu]==1.17.1 ; sys_platform == 'linux'
10641064
10651065_tests .append (_test_pipstar_platforms )
10661066
1067+ def _test_multiple_extras_multiple_requirements (env ):
1068+ """Test that reproduces an issue where multiple extras point to same whl.
1069+
1070+ Based on https://github.com/bazel-contrib/rules_python/issues/2797#issuecomment-3143914644.
1071+ """
1072+
1073+ def mock_simpleapi_download (* _ , ** __ ):
1074+ return {
1075+ "package" : parse_simpleapi_html (
1076+ url = "https://example.com/package" ,
1077+ content = '''
1078+ <a href="package-0.7.0.tar.gz#sha256=4dd8924f171ed73a4f1a6191e2f800ae1745069989b69fabc45593d6b6504003">package-0.7.0.tar.gz</a>
1079+ <a href="package-0.7.0-py3-none-any.whl#sha256=62833036cbaf4641d66ae94c61c0446890a91b2c0d153946583a0ebe04877a76">package-0.7.0-py3-none-any.whl</a>
1080+ ''' ,
1081+ ),
1082+ }
1083+
1084+ builder = hub_builder (
1085+ env ,
1086+ available_interpreters = {
1087+ "python_3_12_host" : "unit_test_interpreter_target" ,
1088+ },
1089+ minor_mapping = {"3.12" : "3.12.11" },
1090+ simpleapi_download_fn = mock_simpleapi_download ,
1091+ )
1092+ builder .pip_parse (
1093+ _mock_mctx (
1094+ read = lambda x : {
1095+ "requirements.linux_arm64.txt" : '''\
1096+ package==0.7.0 \
1097+ --hash=sha256:4dd8924f171ed73a4f1a6191e2f800ae1745069989b69fabc45593d6b6504003 \
1098+ --hash=sha256:62833036cbaf4641d66ae94c61c0446890a91b2c0d153946583a0ebe04877a76
1099+ ''' ,
1100+ "requirements.linux_x86_64.txt" : '''\
1101+ package[extra]==0.7.0 \
1102+ --hash=sha256:62833036cbaf4641d66ae94c61c0446890a91b2c0d153946583a0ebe04877a76
1103+ ''' ,
1104+ }[x ],
1105+ ),
1106+ _parse (
1107+ hub_name = "pypi" ,
1108+ python_version = "3.12" ,
1109+ download_only = True ,
1110+ requirements_by_platform = {
1111+ "requirements.linux_arm64.txt" : "linux_aarch64" ,
1112+ "requirements.linux_x86_64.txt" : "linux_x86_64" ,
1113+ },
1114+ experimental_index_url = "pypi.org" ,
1115+ ),
1116+ )
1117+ pypi = builder .build ()
1118+
1119+ pypi .exposed_packages ().contains_exactly (["package" ])
1120+ pypi .group_map ().contains_exactly ({})
1121+
1122+ # TODO(hartikainen): Check these expectations.
1123+ pypi .whl_map ().contains_exactly ({
1124+ "package" : {
1125+ "pypi_312_package_py3_none_any_62833036" : [
1126+ whl_config_setting (
1127+ # TODO(hartikainen): The two platforms both use the same `.whl` and
1128+ # are thus included in the same `target_platforms` here.
1129+ target_platforms = ["cp312_linux_aarch64" , "cp312_linux_x86_64" ],
1130+ version = "3.12" ,
1131+ ),
1132+ ],
1133+ },
1134+ })
1135+ pypi .whl_libraries ().contains_exactly ({
1136+ # NOTE(hartikainen): The error stems here. We have two different platforms
1137+ # pointing to the same universal wheel, both just with different extras. The key
1138+ # clashes and probably needs the extras to be included in it.
1139+ "pypi_312_package_py3_none_any_62833036" : {
1140+ "config_load" : "@pypi//:config.bzl" ,
1141+ "dep_template" : "@pypi//{name}:{target}" ,
1142+ "filename" : "package-0.7.0-py3-none-any.whl" ,
1143+ "python_interpreter_target" : "unit_test_interpreter_target" ,
1144+ # NOTE(hartikainen): This should say `package[extra]==0.7.0` for
1145+ # `linux_x86_64` platform and `package==0.7.0` for `linux_aarch64`
1146+ "requirement" : "package[extra]==0.7.0" ,
1147+ "sha256" : "62833036cbaf4641d66ae94c61c0446890a91b2c0d153946583a0ebe04877a76" ,
1148+ "urls" : ["https://example.com/package/package-0.7.0-py3-none-any.whl" ],
1149+ },
1150+ })
1151+ pypi .extra_aliases ().contains_exactly ({})
1152+
1153+ _tests .append (_test_multiple_extras_multiple_requirements )
1154+
10671155def hub_builder_test_suite (name ):
10681156 """Create the test suite.
10691157
0 commit comments