Skip to content

Commit 2bd0b42

Browse files
committed
simplify the code base a little
1 parent 872d0c4 commit 2bd0b42

File tree

2 files changed

+24
-49
lines changed

2 files changed

+24
-49
lines changed

python/private/pypi/extension.bzl

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def parse_modules(
168168
enable_pipstar: {type}`bool` a flag to enable dropping Python dependency for
169169
evaluation of the extension.
170170
_fail: {type}`function` the failure function, mainly for testing.
171-
**kwargs: Extra arguments passed to the layers below.
171+
**kwargs: Extra arguments passed to the hub_builder.
172172
173173
Returns:
174174
A struct with the following attributes:
@@ -242,15 +242,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
242242
pip_hub_map = {}
243243
simpleapi_cache = {}
244244

245-
# Keeps track of all the hub's whl repos across the different versions.
246-
# dict[hub, dict[whl, dict[version, str pip]]]
247-
# Where hub, whl, and pip are the repo names
248-
hub_whl_map = {}
249-
hub_group_map = {}
250-
exposed_packages = {}
251-
extra_aliases = {}
252-
whl_libraries = {}
253-
254245
for mod in module_ctx.modules:
255246
for pip_attr in mod.tags.parse:
256247
hub_name = pip_attr.hub_name
@@ -291,62 +282,43 @@ You cannot use both the additive_build_content and additive_build_content_file a
291282
whl_overrides = whl_overrides,
292283
)
293284

285+
# Keeps track of all the hub's whl repos across the different versions.
286+
# dict[hub, dict[whl, dict[version, str pip]]]
287+
# Where hub, whl, and pip are the repo names
288+
hub_whl_map = {}
289+
hub_group_map = {}
290+
exposed_packages = {}
291+
extra_aliases = {}
292+
whl_libraries = {}
294293
for hub in pip_hub_map.values():
295294
out = hub.build()
296295

297296
for whl_name, lib in out.whl_libraries.items():
298297
if whl_name in whl_libraries:
299298
fail("'{}' already in created".format(whl_name))
300299
else:
301-
# replicate whl_libraries.update(out.whl_libraries)
302300
whl_libraries[whl_name] = lib
303301

304-
hub_whl_map[hub.name] = out.whl_map
305-
hub_group_map[hub.name] = out.group_map
306-
extra_aliases[hub.name] = out.extra_aliases
307302
exposed_packages[hub.name] = out.exposed_packages
303+
extra_aliases[hub.name] = out.extra_aliases
304+
hub_group_map[hub.name] = out.group_map
305+
hub_whl_map[hub.name] = out.whl_map
308306

309307
return struct(
310-
# We sort so that the lock-file remains the same no matter the order of how the
311-
# args are manipulated in the code going before.
312-
whl_mods = dict(sorted(whl_mods.items())),
313-
hub_whl_map = {
314-
hub_name: {
315-
whl_name: dict(settings)
316-
for whl_name, settings in sorted(whl_map.items())
317-
}
318-
for hub_name, whl_map in sorted(hub_whl_map.items())
319-
},
320-
hub_group_map = {
321-
hub_name: {
322-
key: sorted(values)
323-
for key, values in sorted(group_map.items())
324-
}
325-
for hub_name, group_map in sorted(hub_group_map.items())
326-
},
327-
exposed_packages = {
328-
k: sorted(v)
329-
for k, v in sorted(exposed_packages.items())
330-
},
331-
extra_aliases = {
332-
hub_name: {
333-
whl_name: sorted(aliases)
334-
for whl_name, aliases in extra_whl_aliases.items()
335-
}
336-
for hub_name, extra_whl_aliases in extra_aliases.items()
337-
},
308+
config = config,
309+
exposed_packages = exposed_packages,
310+
extra_aliases = extra_aliases,
311+
hub_group_map = hub_group_map,
312+
hub_whl_map = hub_whl_map,
313+
whl_libraries = whl_libraries,
314+
whl_mods = whl_mods,
338315
platform_config_settings = {
339316
hub_name: {
340317
platform_name: sorted([str(Label(cv)) for cv in p.config_settings])
341318
for platform_name, p in config.platforms.items()
342319
}
343320
for hub_name in hub_whl_map
344321
},
345-
whl_libraries = {
346-
k: dict(sorted(args.items()))
347-
for k, args in sorted(whl_libraries.items())
348-
},
349-
config = config,
350322
)
351323

352324
def _pip_impl(module_ctx):

python/private/pypi/hub_builder.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ def _build(self):
9494
return struct(
9595
whl_map = whl_map,
9696
group_map = self.group_map,
97-
extra_aliases = self.extra_aliases,
98-
exposed_packages = self.exposed_packages,
97+
extra_aliases = {
98+
whl: sorted(aliases)
99+
for whl, aliases in self.extra_aliases.items()
100+
},
101+
exposed_packages = sorted(self.exposed_packages),
99102
whl_libraries = self.whl_libraries,
100103
)
101104

0 commit comments

Comments
 (0)