Skip to content

Commit 3668385

Browse files
committed
Fix multi-extra issue
1 parent 0d22a40 commit 3668385

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

python/private/pypi/extension.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ def _whl_repo(
421421
repo_name = pypi_repo_name(
422422
normalize_name(src.distribution),
423423
target_platforms = target_platforms,
424+
extras = src.extras,
424425
),
425426
args = args,
426427
config_setting = whl_config_setting(
@@ -450,7 +451,7 @@ def _whl_repo(
450451
]
451452

452453
return struct(
453-
repo_name = whl_repo_name(src.filename, src.sha256),
454+
repo_name = whl_repo_name(src.filename, src.sha256, src.extras),
454455
args = args,
455456
config_setting = whl_config_setting(
456457
version = python_version,

python/private/pypi/parse_requirements.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def parse_requirements(
133133
extra_pip_args = options[target_platform]
134134

135135
for distribution, requirement_line in reqs_:
136+
req = requirement(requirement_line)
136137
for_whl = requirements_by_platform.setdefault(
137138
normalize_name(distribution),
138139
{},
@@ -146,6 +147,7 @@ def parse_requirements(
146147
struct(
147148
distribution = distribution,
148149
srcs = index_sources(requirement_line),
150+
extras = req.extras,
149151
requirement_line = requirement_line,
150152
target_platforms = [],
151153
extra_pip_args = extra_pip_args,
@@ -269,6 +271,7 @@ def _package_srcs(
269271
distribution = name,
270272
extra_pip_args = r.extra_pip_args,
271273
requirement_line = req_line,
274+
extras = r.extras,
272275
target_platforms = [],
273276
filename = dist.filename,
274277
sha256 = dist.sha256,

python/private/pypi/whl_repo_name.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def whl_repo_name(filename, sha256, extras=[]):
5656
parts.append(python_tag)
5757
parts.append(abi_tag)
5858
parts.append(platform_tag)
59-
parts.extend(sorted(extras))
59+
parts.extend(sorted([e for e in extras if e]))
6060

6161
if sha256:
6262
parts.append(sha256[:8])

tests/pypi/extension/extension_tests.bzl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,31 +458,37 @@ package[extra]==0.7.0 \
458458
)
459459

460460
pypi.exposed_packages().contains_exactly({"pypi": ["package"]})
461-
# TODO(hartikainen): Check these expectations.
462461
pypi.hub_whl_map().contains_exactly({"pypi": {
463462
"package": {
464463
"pypi_312_package_py3_none_any_62833036": [
465464
whl_config_setting(
466-
# TODO(hartikainen): The two platforms both use the same `.whl` and
467-
# are thus included in the same `target_platforms` here.
468-
target_platforms = ["cp312_linux_aarch64", "cp312_linux_x86_64"],
465+
target_platforms = ["cp312_linux_aarch64"],
466+
version = "3.12",
467+
),
468+
],
469+
"pypi_312_package_py3_none_any_extra_62833036": [
470+
whl_config_setting(
471+
target_platforms = ["cp312_linux_x86_64"],
469472
version = "3.12",
470473
),
471474
],
472475
},
473476
}})
474477
pypi.whl_libraries().contains_exactly({
475-
# NOTE(hartikainen): The error stems here. We have two different platforms
476-
# pointing to the same universal wheel, both just with different extras. The key
477-
# clashes and probably needs the extras to be included in it.
478478
"pypi_312_package_py3_none_any_62833036": {
479479
"dep_template": "@pypi//{name}:{target}",
480-
"download_only": True,
481-
"experimental_target_platforms": ["linux_aarch64", "linux_x86_64"],
480+
"experimental_target_platforms": ["linux_aarch64"],
481+
"filename": "package-0.7.0-py3-none-any.whl",
482+
"python_interpreter_target": "unit_test_interpreter_target",
483+
"requirement": "package==0.7.0",
484+
"sha256": "62833036cbaf4641d66ae94c61c0446890a91b2c0d153946583a0ebe04877a76",
485+
"urls": ["https://example.com/package/package-0.7.0-py3-none-any.whl"],
486+
},
487+
"pypi_312_package_py3_none_any_extra_62833036": {
488+
"dep_template": "@pypi//{name}:{target}",
489+
"experimental_target_platforms": ["linux_x86_64"],
482490
"filename": "package-0.7.0-py3-none-any.whl",
483491
"python_interpreter_target": "unit_test_interpreter_target",
484-
# NOTE(hartikainen): This should say `package[extra]==0.7.0` for
485-
# `linux_x86_64` platform and `package==0.7.0` for `linux_aarch64`
486492
"requirement": "package[extra]==0.7.0",
487493
"sha256": "62833036cbaf4641d66ae94c61c0446890a91b2c0d153946583a0ebe04877a76",
488494
"urls": ["https://example.com/package/package-0.7.0-py3-none-any.whl"],

0 commit comments

Comments
 (0)