Skip to content

Commit 2f16f3d

Browse files
committed
Enable extras in {whl,pypi}_repo_name
1 parent be0dcd3 commit 2f16f3d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

python/private/pypi/hub_builder.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ def _whl_repo(
538538
repo_name = pypi_repo_name(
539539
whl_name = normalize_name(src.distribution),
540540
target_platforms = target_platforms,
541+
extras = src.extras,
541542
),
542543
args = args,
543544
config_setting = whl_config_setting(
@@ -567,7 +568,7 @@ def _whl_repo(
567568
]
568569

569570
return struct(
570-
repo_name = whl_repo_name(src.filename, src.sha256),
571+
repo_name = whl_repo_name(src.filename, src.sha256, extras = src.extras),
571572
args = args,
572573
config_setting = whl_config_setting(
573574
version = python_version,

python/private/pypi/parse_requirements.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def _package_srcs(
274274
sha256 = dist.sha256,
275275
url = dist.url,
276276
yanked = dist.yanked,
277+
extras = requirement(r.requirement_line).extras,
277278
),
278279
)
279280

python/private/pypi/whl_repo_name.bzl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
load("//python/private:normalize_name.bzl", "normalize_name")
1919
load(":parse_whl_name.bzl", "parse_whl_name")
2020

21-
def whl_repo_name(filename, sha256):
21+
def whl_repo_name(filename, sha256, extras = []):
2222
"""Return a valid whl_library repo name given a distribution filename.
2323
2424
Args:
@@ -59,9 +59,12 @@ def whl_repo_name(filename, sha256):
5959
elif version:
6060
parts.insert(1, version)
6161

62+
if extras:
63+
parts.extend(sorted([e for e in extras if e]))
64+
6265
return "_".join(parts)
6366

64-
def pypi_repo_name(whl_name, target_platforms = []):
67+
def pypi_repo_name(whl_name, target_platforms = [], extras = []):
6568
"""Return a valid whl_library given a requirement line.
6669
6770
Args:
@@ -76,4 +79,7 @@ def pypi_repo_name(whl_name, target_platforms = []):
7679
]
7780
parts.extend([p.partition("_")[-1] for p in target_platforms])
7881

82+
if extras:
83+
parts.extend(sorted([e for e in extras if e]))
84+
7985
return "_".join(parts)

0 commit comments

Comments
 (0)