Skip to content

Commit 62dccd5

Browse files
committed
seam: add a build function
1 parent a636ca6 commit 62dccd5

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

python/private/pypi/extension.bzl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -517,22 +517,19 @@ You cannot use both the additive_build_content and additive_build_content_file a
517517
)
518518

519519
for hub in pip_hub_map.values():
520-
hub_whl_map.setdefault(hub.name, {})
521-
for key, settings in hub.whl_map.items():
522-
for setting, repo in settings.items():
523-
hub_whl_map[hub.name].setdefault(key, {}).setdefault(repo, []).append(setting)
524-
525-
whl_libraries.update(hub.whl_libraries)
526-
for whl_name, lib in hub.whl_libraries.items():
527-
if whl_name in lib:
520+
out = hub.build()
521+
522+
for whl_name, lib in out.whl_libraries.items():
523+
if whl_name in whl_libraries:
528524
fail("'{}' already in created".format(whl_name))
529525
else:
530526
# replicate whl_libraries.update(out.whl_libraries)
531527
whl_libraries[whl_name] = lib
532528

533-
hub_group_map[hub.name] = hub.group_map
534-
extra_aliases[hub.name] = hub.extra_aliases
535-
exposed_packages[hub.name] = hub.exposed_packages
529+
hub_whl_map[hub.name] = out.whl_map
530+
hub_group_map[hub.name] = out.group_map
531+
extra_aliases[hub.name] = out.extra_aliases
532+
exposed_packages[hub.name] = out.exposed_packages
536533

537534
return struct(
538535
# We sort so that the lock-file remains the same no matter the order of how the

python/private/pypi/hub_builder.bzl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,26 @@ def hub_builder(
6868
python_version in self._get_index_urls,
6969
),
7070
evaluate_markers = lambda *a, **k: _evaluate_markers(self, *a, **k),
71+
build = lambda: _build(self),
7172
)
7273

7374
# buildifier: enable=uninitialized
7475
return self
7576

77+
def _build(self):
78+
whl_map = {}
79+
for key, settings in self.whl_map.items():
80+
for setting, repo in settings.items():
81+
whl_map.setdefault(key, {}).setdefault(repo, []).append(setting)
82+
83+
return struct(
84+
whl_map = whl_map,
85+
group_map = self.group_map,
86+
extra_aliases = self.extra_aliases,
87+
exposed_packages = self.exposed_packages,
88+
whl_libraries = self.whl_libraries,
89+
)
90+
7691
def _add(self, *, pip_attr):
7792
python_version = pip_attr.python_version
7893
if python_version in self.python_versions:

0 commit comments

Comments
 (0)