Skip to content

Commit 6642756

Browse files
committed
refactor: pass get_index_urls function to _create_whl_repos
1 parent 03cc7b5 commit 6642756

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
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: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _create_whl_repos(
6767
*,
6868
pip_attr,
6969
whl_overrides,
70-
simpleapi_cache):
70+
get_index_urls = None):
7171
exposed_packages = {}
7272
whl_libraries = {}
7373
group_map = {}
@@ -135,24 +135,6 @@ def _create_whl_repos(
135135

136136
# Create a new wheel library for each of the different whls
137137

138-
get_index_urls = None
139-
if pip_attr.experimental_index_url:
140-
get_index_urls = lambda ctx, distributions: simpleapi_download(
141-
ctx,
142-
attr = struct(
143-
index_url = pip_attr.experimental_index_url,
144-
extra_index_urls = pip_attr.experimental_extra_index_urls or [],
145-
index_url_overrides = pip_attr.experimental_index_url_overrides or {},
146-
sources = distributions,
147-
envsubst = pip_attr.envsubst,
148-
# Auth related info
149-
netrc = pip_attr.netrc,
150-
auth_patterns = pip_attr.auth_patterns,
151-
),
152-
cache = simpleapi_cache,
153-
parallel_download = pip_attr.parallel_download,
154-
)
155-
156138
requirements_by_platform = parse_requirements(
157139
module_ctx,
158140
requirements_by_platform = requirements_files_by_platform(
@@ -461,11 +443,29 @@ You cannot use both the additive_build_content and additive_build_content_file a
461443
else:
462444
pip_hub_map[pip_attr.hub_name].python_versions.append(pip_attr.python_version)
463445

446+
get_index_urls = None
447+
if pip_attr.experimental_index_url:
448+
get_index_urls = lambda ctx, distributions: simpleapi_download(
449+
ctx,
450+
attr = struct(
451+
index_url = pip_attr.experimental_index_url,
452+
extra_index_urls = pip_attr.experimental_extra_index_urls or [],
453+
index_url_overrides = pip_attr.experimental_index_url_overrides or {},
454+
sources = distributions,
455+
envsubst = pip_attr.envsubst,
456+
# Auth related info
457+
netrc = pip_attr.netrc,
458+
auth_patterns = pip_attr.auth_patterns,
459+
),
460+
cache = simpleapi_cache,
461+
parallel_download = pip_attr.parallel_download,
462+
)
463+
464464
result = _create_whl_repos(
465465
module_ctx,
466466
pip_attr = pip_attr,
467-
simpleapi_cache = simpleapi_cache,
468467
whl_overrides = whl_overrides,
468+
get_index_urls = get_index_urls,
469469
)
470470
whl_libraries.update(result.whl_libraries)
471471
for hub, config_settings in result.whl_map.items():

0 commit comments

Comments
 (0)