Skip to content

Commit d4d2453

Browse files
committed
feat(pip): global downloader settings
1 parent 79f6546 commit d4d2453

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

python/private/pypi/extension.bzl

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ def build_config(
115115
# extra values that we just add
116116
auth_patterns = tag.auth_patterns,
117117
netrc = tag.netrc,
118+
use_downloader = tag.user_downloader,
119+
parallel_download = tag.parallel_download,
120+
index_url_overrides = tag.index_url_overrides,
121+
downloader_skip = tag.downloader_skip,
118122
# TODO @aignas 2025-05-19: add more attr groups:
119123
# * for index/downloader config. This includes all of those attributes for
120124
# overrides, etc. Index overrides per platform could be also used here.
@@ -525,7 +529,72 @@ supported from this version without extra handling from the user.
525529
:::
526530
""",
527531
),
528-
} | AUTH_ATTRS
532+
} | AUTH_ATTRS | {
533+
# Downloader options
534+
"downloader": attr.string(
535+
values = ["disabled", "debug", "enabled", "auto"],
536+
default = "auto",
537+
doc = """\
538+
Option values:
539+
* `disabled` - disable downloader.
540+
* `debug` - stop using parallel downloading for debugging cases.
541+
* `enabled` - enable downloader for all hubs.
542+
* `auto` - use the downloader if `experimental_index_url` is passed.
543+
544+
The default index URL is defined by the {attr}`index_url` with overrides taken from
545+
`index_overrides`. If the package is not found in the index, we will search all of the indexes
546+
listed in the lock files used to create a particular hub repository.
547+
548+
TODO: experimental and docs in flux.
549+
550+
:::{versionadded} VERSION_NEXT_FEATURE
551+
:::
552+
""",
553+
),
554+
"index_overrides": attr.string_dict(
555+
doc = """\
556+
The index URL overrides for each package to use for downloading wheels using
557+
bazel downloader. This value is going to be subject to `envsubst` substitutions
558+
if necessary.
559+
560+
The key is the package name (will be normalized before usage) and the value is the
561+
index URL.
562+
563+
This design pattern has been chosen in order to be fully deterministic about which
564+
packages come from which source. We want to avoid issues similar to what happened in
565+
https://pytorch.org/blog/compromised-nightly-dependency/.
566+
567+
The indexes must support Simple API as described here:
568+
<https://packaging.python.org/en/latest/specifications/simple-repository-api/>
569+
570+
If `skip` is used as a value, then we will not use the downloader for a particular package. The
571+
values by `root` module take precedence over all others and non-root module precedence is
572+
undefined.
573+
574+
TODO: experimental
575+
TODO: implement skip
576+
577+
:::{versionadded} VERSION_NEXT_FEATURE
578+
:::
579+
""",
580+
),
581+
"index_url": attr.string(
582+
doc = """\
583+
The index URL to use for downloading wheels using bazel downloader. This value is going
584+
to be subject to `envsubst` substitutions if necessary.
585+
586+
The indexes must support Simple API as described here:
587+
<https://packaging.python.org/en/latest/specifications/simple-repository-api/>.
588+
589+
Note, this is used for *all* repositories by this feature, so that root modules can override the
590+
value to use a private mirror if necessary.
591+
592+
:::{versionadded} VERSION_NEXT_FEATURE
593+
:::
594+
""",
595+
default = "${PYPI_INDEX_URL:-https://pypi.org/simple}",
596+
),
597+
}
529598

530599
_SUPPORTED_PEP508_KEYS = [
531600
"implementation_name",

0 commit comments

Comments
 (0)