Skip to content

Commit 03cc7b5

Browse files
committed
refactor: remove side effects in _create_whl_repos
1 parent d53e91b commit 03cc7b5

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

examples/bzlmod/MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/private/pypi/extension.bzl

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,17 @@ def _whl_mods_impl(whl_mods_dict):
6262
whl_mods = whl_mods,
6363
)
6464

65-
def _create_whl_repos(module_ctx, *, pip_attr, whl_map, whl_overrides, group_map, simpleapi_cache, exposed_packages, whl_libraries):
65+
def _create_whl_repos(
66+
module_ctx,
67+
*,
68+
pip_attr,
69+
whl_overrides,
70+
simpleapi_cache):
71+
exposed_packages = {}
72+
whl_libraries = {}
73+
group_map = {}
74+
whl_map = {}
75+
6676
logger = repo_utils.logger(module_ctx, "pypi:create_whl_repos")
6777
python_interpreter_target = pip_attr.python_interpreter_target
6878
is_hub_reproducible = True
@@ -319,7 +329,13 @@ def _create_whl_repos(module_ctx, *, pip_attr, whl_map, whl_overrides, group_map
319329
),
320330
)
321331

322-
return is_hub_reproducible
332+
return struct(
333+
exposed_packages = exposed_packages,
334+
group_map = group_map,
335+
is_hub_reproducible = is_hub_reproducible,
336+
whl_libraries = whl_libraries,
337+
whl_map = whl_map,
338+
)
323339

324340
def parse_modules(module_ctx, _fail = fail):
325341
"""Implementation of parsing the tag classes for the extension and return a struct for registering repositories.
@@ -445,17 +461,19 @@ You cannot use both the additive_build_content and additive_build_content_file a
445461
else:
446462
pip_hub_map[pip_attr.hub_name].python_versions.append(pip_attr.python_version)
447463

448-
is_hub_reproducible = _create_whl_repos(
464+
result = _create_whl_repos(
449465
module_ctx,
450-
exposed_packages = exposed_packages,
451-
group_map = hub_group_map,
452466
pip_attr = pip_attr,
453467
simpleapi_cache = simpleapi_cache,
454-
whl_map = hub_whl_map,
455468
whl_overrides = whl_overrides,
456-
whl_libraries = whl_libraries,
457469
)
458-
is_reproducible = is_reproducible and is_hub_reproducible
470+
whl_libraries.update(result.whl_libraries)
471+
for hub, config_settings in result.whl_map.items():
472+
for whl, settings in config_settings.items():
473+
hub_whl_map.setdefault(hub, {}).setdefault(whl, []).extend(settings)
474+
hub_group_map.update(result.group_map)
475+
exposed_packages.update(result.exposed_packages)
476+
is_reproducible = is_reproducible and result.is_hub_reproducible
459477

460478
return struct(
461479
whl_mods = whl_mods,

0 commit comments

Comments
 (0)