Skip to content

Commit 4637132

Browse files
committed
wip
1 parent e97cb9e commit 4637132

3 files changed

Lines changed: 40 additions & 48 deletions

File tree

python/private/pypi/hub_builder.bzl

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ load(":attrs.bzl", "use_isolated")
1111
load(":parse_requirements.bzl", "parse_requirements")
1212
load(":pep508_env.bzl", "env")
1313
load(":pep508_evaluate.bzl", "evaluate")
14+
load(":pep508_requirement.bzl", "requirement")
1415
load(":python_tag.bzl", "python_tag")
1516
load(":requirements_files_by_platform.bzl", "requirements_files_by_platform")
1617
load(":whl_config_setting.bzl", "whl_config_setting")
@@ -332,28 +333,38 @@ def _add_whl_library(self, *, python_version, whl, repo):
332333
repos_dict = self._whl_libraries
333334
deps_args = repo.args
334335
else:
336+
extract_args = {
337+
k: v
338+
for k, v in repo.args.items()
339+
if k not in forbidden_args | {
340+
"config_load": None,
341+
"dep_template": None,
342+
}
343+
}
344+
req = requirement(extract_args["requirement"])
345+
346+
# TODO @aignas 2026-07-04: add a test
347+
extract_args["requirement"] = req.name # drop any specified extras
335348
_add_library(
336349
self,
337350
repos_dict = self._whl_libraries,
338351
name = repo.whl_repo_name,
339-
args = {
340-
k: v
341-
for k, v in repo.args.items()
342-
if k not in forbidden_args | {
343-
"config_load": None,
344-
"dep_template": None,
345-
}
346-
},
352+
args = extract_args,
347353
)
348354

349-
args = repo.args
350-
351-
deps_args = {}
352-
for key in ("config_load", "dep_template", "group_deps", "group_name", "annotation", "pip_data_exclude"):
353-
if key in args and args[key] != None:
354-
deps_args[key] = args[key]
355-
356-
deps_args["whl_library"] = "@{}//:BUILD.bazel".format(repo.whl_repo_name)
355+
deps_args = {
356+
k: repo.args[k]
357+
for k in [
358+
"config_load",
359+
"dep_template",
360+
"group_deps",
361+
"group_name",
362+
]
363+
} | {
364+
# TODO @aignas 2026-07-04: add a test
365+
"extras": req.extras,
366+
"whl_library": "@{}//:BUILD.bazel".format(repo.whl_repo_name),
367+
}
357368
repos_dict = self._whl_library_deps
358369

359370
repo_name = "{}_{}_{}".format(self.name, version_label(python_version), repo.repo_name)

python/private/pypi/whl_library.bzl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,6 @@ def _whl_library_deps_impl(rctx):
662662

663663
whl_library_deps = repository_rule(
664664
attrs = {
665-
"annotation": attr.label(
666-
doc = "Optional json encoded file containing annotation to apply to the extracted wheel.",
667-
allow_files = True,
668-
),
669665
"config_load": attr.string(
670666
doc = "The load location for configuration for pipstar.",
671667
),
@@ -683,10 +679,6 @@ whl_library_deps = repository_rule(
683679
"group_name": attr.string(
684680
doc = "Name of the group, if any.",
685681
),
686-
"pip_data_exclude": attr.string_list(
687-
doc = "Additional data exclude patterns.",
688-
default = [],
689-
),
690682
"whl_library": attr.label(
691683
doc = "The whl_library repository label, use BUILD.bazel file for this.",
692684
mandatory = True,

tests/pypi/hub_builder/hub_builder_tests.bzl

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -291,39 +291,30 @@ def _test_simple_extras_vs_no_extras_simpleapi(env):
291291
pypi.group_map().contains_exactly({})
292292
pypi.whl_map().contains_exactly({
293293
"simple": {
294-
"pypi_315_simple_py3_none_any_deadbeef_osx_aarch64": [
294+
"pypi_315_simple_py3_none_any_deadbeef": [
295295
whl_config_setting(
296296
target_platforms = [
297-
"cp315_osx_aarch64",
297+
"cp315_windows_aarch64",
298298
],
299299
version = "3.15",
300300
),
301-
],
302-
"pypi_315_simple_py3_none_any_deadbeef_windows_aarch64": [
303301
whl_config_setting(
304302
target_platforms = [
305-
"cp315_windows_aarch64",
303+
"cp315_osx_aarch64",
306304
],
307305
version = "3.15",
308306
),
309307
],
310308
},
311309
})
312310
pypi.whl_libraries().contains_exactly({
313-
"simple_py3_none_any_deadbeef_osx_aarch64": {
311+
"simple_py3_none_any_deadbeef": {
314312
"filename": "simple-0.0.1-py3-none-any.whl",
315313
"index_url": "https://example.com/simple",
316314
"requirement": "simple[foo]==0.0.1",
317315
"sha256": "deadbeef",
318316
"urls": ["/simple-0.0.1-py3-none-any.whl"],
319317
},
320-
"simple_py3_none_any_deadbeef_windows_aarch64": {
321-
"filename": "simple-0.0.1-py3-none-any.whl",
322-
"index_url": "https://example.com/simple",
323-
"requirement": "simple==0.0.1",
324-
"sha256": "deadbeef",
325-
"urls": ["/simple-0.0.1-py3-none-any.whl"],
326-
},
327318
})
328319
pypi.extra_aliases().contains_exactly({})
329320

@@ -611,25 +602,25 @@ torch==2.4.1+cpu ; platform_machine == 'x86_64' \
611602
pypi.group_map().contains_exactly({})
612603
pypi.whl_map().contains_exactly({
613604
"torch": {
614-
"pypi_312_torch_cp312_cp312_linux_x86_64_8800deef_linux_x86_64": [
605+
"pypi_312_torch_cp312_cp312_linux_x86_64_8800deef": [
615606
whl_config_setting(
616607
target_platforms = ["cp312_linux_x86_64"],
617608
version = "3.12",
618609
),
619610
],
620-
"pypi_312_torch_cp312_cp312_manylinux_2_17_aarch64_36109432_linux_aarch64": [
611+
"pypi_312_torch_cp312_cp312_manylinux_2_17_aarch64_36109432": [
621612
whl_config_setting(
622613
target_platforms = ["cp312_linux_aarch64"],
623614
version = "3.12",
624615
),
625616
],
626-
"pypi_312_torch_cp312_cp312_win_amd64_3a570e5c_windows_x86_64": [
617+
"pypi_312_torch_cp312_cp312_win_amd64_3a570e5c": [
627618
whl_config_setting(
628619
target_platforms = ["cp312_windows_x86_64"],
629620
version = "3.12",
630621
),
631622
],
632-
"pypi_312_torch_cp312_none_macosx_11_0_arm64_72b484d5_osx_aarch64": [
623+
"pypi_312_torch_cp312_none_macosx_11_0_arm64_72b484d5": [
633624
whl_config_setting(
634625
target_platforms = ["cp312_osx_aarch64"],
635626
version = "3.12",
@@ -638,28 +629,28 @@ torch==2.4.1+cpu ; platform_machine == 'x86_64' \
638629
},
639630
})
640631
pypi.whl_libraries().contains_exactly({
641-
"torch_cp312_cp312_linux_x86_64_8800deef_linux_x86_64": {
632+
"torch_cp312_cp312_linux_x86_64_8800deef": {
642633
"filename": "torch-2.4.1+cpu-cp312-cp312-linux_x86_64.whl",
643634
"index_url": "https://torch.index/torch",
644635
"requirement": "torch==2.4.1+cpu",
645636
"sha256": "8800deef0026011d502c0c256cc4b67d002347f63c3a38cd8e45f1f445c61364",
646637
"urls": ["/whl/cpu/torch-2.4.1%2Bcpu-cp312-cp312-linux_x86_64.whl"],
647638
},
648-
"torch_cp312_cp312_manylinux_2_17_aarch64_36109432_linux_aarch64": {
639+
"torch_cp312_cp312_manylinux_2_17_aarch64_36109432": {
649640
"filename": "torch-2.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
650641
"index_url": "https://torch.index/torch",
651642
"requirement": "torch==2.4.1",
652643
"sha256": "36109432b10bd7163c9b30ce896f3c2cca1b86b9765f956a1594f0ff43091e2a",
653644
"urls": ["/whl/cpu/torch-2.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl"],
654645
},
655-
"torch_cp312_cp312_win_amd64_3a570e5c_windows_x86_64": {
646+
"torch_cp312_cp312_win_amd64_3a570e5c": {
656647
"filename": "torch-2.4.1+cpu-cp312-cp312-win_amd64.whl",
657648
"index_url": "https://torch.index/torch",
658649
"requirement": "torch==2.4.1+cpu",
659650
"sha256": "3a570e5c553415cdbddfe679207327b3a3806b21c6adea14fba77684d1619e97",
660651
"urls": ["/whl/cpu/torch-2.4.1%2Bcpu-cp312-cp312-win_amd64.whl"],
661652
},
662-
"torch_cp312_none_macosx_11_0_arm64_72b484d5_osx_aarch64": {
653+
"torch_cp312_none_macosx_11_0_arm64_72b484d5": {
663654
"filename": "torch-2.4.1-cp312-none-macosx_11_0_arm64.whl",
664655
"index_url": "https://torch.index/torch",
665656
"requirement": "torch==2.4.1",
@@ -1478,12 +1469,10 @@ Attempting to create a duplicate library pypi_315_foo with different arguments.
14781469
common: {
14791470
"dep_template": "@pypi//{name}:{target}",
14801471
"config_load": "@pypi//:config.bzl",
1481-
"requirement": "foo==0.0.1",
14821472
}
14831473
different: {
14841474
"python_interpreter_target": ("unit_test_interpreter_target_1", "unit_test_interpreter_target_2"),
1485-
}\
1486-
""",
1475+
}""",
14871476
]).in_order()
14881477

14891478
_tests.append(_test_err_duplicate_repos)

0 commit comments

Comments
 (0)