Skip to content

Commit 3608e1d

Browse files
committed
fixup
1 parent c3a21b3 commit 3608e1d

4 files changed

Lines changed: 44 additions & 9 deletions

File tree

python/private/pypi/extension.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
474474
if whl_name in whl_libraries:
475475
existing = whl_libraries[whl_name]
476476

477-
# TODO @aignas 2026-07-04: stop ignoring the index_url
478-
diff = _diff_dict(existing, lib, ignore_keys = {"index_url": True})
477+
diff = _diff_dict(existing, lib)
479478
if diff:
480479
fail("'{}' already in created:\n{}".format(
481480
whl_name,
@@ -1251,6 +1250,7 @@ def _diff_dict(first, second, *, ignore_keys = {}):
12511250
Args:
12521251
first: The first dictionary to compare.
12531252
second: The second dictionary to compare.
1253+
ignore_keys: A set of keys to ignore during comparison.
12541254
12551255
Returns:
12561256
A dictionary containing the differences, with keys "common", "different",

python/private/pypi/generate_whl_library_build_bazel.bzl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,26 @@ def generate_whl_library_build_bazel(
7777
"""Generate a BUILD file for an unzipped Wheel
7878
7979
Args:
80+
name: The name of the target.
8081
annotation: The annotation for the build file.
8182
config_load: {type}`str` The location from where to load the config.
83+
copy_executables: A mapping of file paths to executable names.
84+
copy_files: A mapping of file paths to file names.
85+
data_exclude: A list of files to exclude from data.
86+
dep_template: The template for dependencies.
87+
enable_implicit_namespace_pkgs: Whether to enable implicit namespace packages.
88+
entry_points: A mapping of entry points.
89+
extras: A list of extras.
90+
group_deps: A list of grouped dependencies.
91+
group_name: The name of the group.
92+
metadata_name: The name of the package.
93+
metadata_version: The version of the package.
94+
namespace_package_files: A mapping of namespace package files.
8295
purl: The purl.
8396
requires_dist: {type}`list[str]` The list of dependencies from the METADATA file.
97+
sdist_filename: The filename of the sdist.
98+
srcs_exclude: A list of source files to exclude.
99+
visibility: The visibility of the target.
84100
**kwargs: Extra args serialized to be passed to the
85101
{obj}`whl_library_targets`.
86102
@@ -182,10 +198,20 @@ def generate_whl_library_deps_build_bazel(
182198
group_deps,
183199
group_name,
184200
requires_dist,
185-
whl_library,
186-
**kwargs):
201+
whl_library):
187202
"""Generate a BUILD file for an unzipped Wheel
188203
204+
Args:
205+
name: The name of the target.
206+
version: The version of the package.
207+
config_load: The location from where to load the config.
208+
dep_template: The template for dependencies.
209+
entry_points: A mapping of entry points.
210+
extras: A list of extras.
211+
group_deps: A list of grouped dependencies.
212+
group_name: The name of the group.
213+
requires_dist: The list of dependencies from the METADATA file.
214+
whl_library: The wheel library target.
189215
190216
Returns:
191217
A complete BUILD file as a string

python/private/pypi/hub_builder.bzl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def hub_builder(
9090
# Functions to download according to the config
9191
# dict[str python_version, callable]
9292
_get_index_urls = {},
93+
_default_index_url = {},
9394
# Tells whether to use the downloader for a package.
9495
# dict[str python_version, dict[str package_name, bool use_downloader]]
9596
_use_downloader = {},
@@ -385,32 +386,33 @@ def _add_library(self, *, repos_dict, name, args):
385386
repos_dict[name] = args
386387

387388
def _set_get_index_urls(self, mctx, pip_attr):
389+
python_version = pip_attr.python_version
390+
388391
# Resolve the index URL through envsubst so the ``$VAR`` / ``${VAR:-default}``
389392
# form is honored when deciding whether the experimental index-url mode is
390393
# active. Without this, an unsubstituted template like ``$RULES_PYTHON_PIP_INDEX_URL``
391394
# is treated as truthy and the mode is forced on, even when the env var
392395
# would expand to the empty string.
393-
default_index_url = envsubst(
396+
self._default_index_url[python_version] = envsubst(
394397
pip_attr.experimental_index_url,
395398
pip_attr.envsubst,
396399
mctx.getenv,
397400
) or self._config.index_url
398401
default_extra_index_urls = pip_attr.experimental_extra_index_urls or []
399402

400-
if not default_index_url:
403+
if not self._default_index_url[python_version]:
401404
# parallel_download is set to True by default, so we are not checking/validating it
402405
# here
403406
return False
404407

405-
python_version = pip_attr.python_version
406408
self._use_downloader.setdefault(python_version, {}).update({
407409
normalize_name(s): False
408410
for s in pip_attr.simpleapi_skip
409411
})
410412
self._get_index_urls[python_version] = lambda ctx, distributions, *, index_url = None, extra_index_urls = None: self._simpleapi_download_fn(
411413
ctx,
412414
attr = struct(
413-
index_url = (index_url or default_index_url).rstrip("/"),
415+
index_url = (index_url or self._default_index_url[python_version]).rstrip("/"),
414416
extra_index_urls = [
415417
x.rstrip("/")
416418
for x in (extra_index_urls or default_extra_index_urls)
@@ -579,7 +581,13 @@ def _create_whl_repos(
579581
for src in whl.srcs:
580582
repo = _whl_repo(
581583
src = src,
582-
index_url = whl.index_url,
584+
index_url = (
585+
whl.index_url or
586+
"{}/{}".format(
587+
self._default_index_url[python_version],
588+
whl.name,
589+
)
590+
).rstrip("/"),
583591
whl_library_args = whl_library_args,
584592
download_only = pip_attr.download_only,
585593
netrc = self._config.netrc or pip_attr.netrc,

python/private/pypi/whl_library_targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def whl_library_targets(
146146
contains this library. If set, this library will behave as a shim
147147
to group implementation rules which will provide simultaneously
148148
installed dependencies which would otherwise form a cycle.
149+
aliases: {type}`list[str]` A list of aliases to create for the target.
149150
src_pkg: TODO
150151
native: {type}`native` The native struct for overriding in tests.
151152
rules: {type}`struct` A struct with references to rules for creating targets.

0 commit comments

Comments
 (0)