Skip to content

Commit f7e65fe

Browse files
committed
remove attributes from the legacy extension
1 parent fd47903 commit f7e65fe

File tree

3 files changed

+34
-30
lines changed

3 files changed

+34
-30
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: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
load("@bazel_features//:features.bzl", "bazel_features")
1818
load("@pythons_hub//:interpreters.bzl", "INTERPRETER_LABELS")
19-
load("//python/private:auth.bzl", "AUTH_ATTRS")
2019
load("//python/private:normalize_name.bzl", "normalize_name")
2120
load("//python/private:repo_utils.bzl", "repo_utils")
2221
load("//python/private:semver.bzl", "semver")
@@ -86,7 +85,14 @@ You cannot use both the additive_build_content and additive_build_content_file a
8685
whl_mods = whl_mods,
8786
)
8887

89-
def _create_whl_repos(module_ctx, pip_attr, whl_map, whl_overrides, group_map, simpleapi_cache, exposed_packages):
88+
def _create_whl_repos(
89+
module_ctx,
90+
pip_attr,
91+
whl_map,
92+
whl_overrides,
93+
group_map,
94+
simpleapi_cache,
95+
exposed_packages):
9096
logger = repo_utils.logger(module_ctx, "pypi:create_whl_repos")
9197
python_interpreter_target = pip_attr.python_interpreter_target
9298
is_hub_reproducible = True
@@ -151,9 +157,6 @@ def _create_whl_repos(module_ctx, pip_attr, whl_map, whl_overrides, group_map, s
151157

152158
get_index_urls = None
153159
if getattr(pip_attr, "index_url", None):
154-
if pip_attr.download_only:
155-
fail("Currently unsupported to use `download_only` and `index_url`")
156-
157160
get_index_urls = lambda ctx, distributions: simpleapi_download(
158161
ctx,
159162
attr = struct(
@@ -229,7 +232,7 @@ def _create_whl_repos(module_ctx, pip_attr, whl_map, whl_overrides, group_map, s
229232
maybe_args = dict(
230233
# The following values are safe to omit if they have false like values
231234
annotation = annotation,
232-
download_only = pip_attr.download_only,
235+
download_only = getattr(pip_attr, "download_only", None),
233236
enable_implicit_namespace_pkgs = pip_attr.enable_implicit_namespace_pkgs,
234237
environment = pip_attr.environment,
235238
envsubst = pip_attr.envsubst,
@@ -284,9 +287,6 @@ def _create_whl_repos(module_ctx, pip_attr, whl_map, whl_overrides, group_map, s
284287
# need to pass the extra args there.
285288
pass
286289

287-
# This is no-op because pip is not used to download the wheel.
288-
whl_library_args.pop("download_only", None)
289-
290290
repo_name = whl_repo_name(pip_name, distribution.filename, distribution.sha256)
291291
whl_library_args["requirement"] = requirement.srcs.requirement
292292
whl_library_args["urls"] = [distribution.url]
@@ -318,7 +318,7 @@ def _create_whl_repos(module_ctx, pip_attr, whl_map, whl_overrides, group_map, s
318318

319319
requirement = select_requirement(
320320
requirements,
321-
platform = None if pip_attr.download_only else repository_platform,
321+
platform = None if getattr(pip_attr, "download_only", None) else repository_platform,
322322
)
323323
if not requirement:
324324
# Sometimes the package is not present for host platform if there
@@ -553,23 +553,6 @@ hubs can be created, and each program can use its respective hub's targets.
553553
Targets from different hubs should not be used together.
554554
""",
555555
),
556-
"parallel_download": attr.bool(
557-
doc = """\
558-
The flag allows to make use of parallel downloading feature in bazel 7.1 and above
559-
when the bazel downloader is used. This is by default enabled as it improves the
560-
performance by a lot, but in case the queries to the simple API are very expensive
561-
or when debugging authentication issues one may want to disable this feature.
562-
563-
NOTE, This will download (potentially duplicate) data for multiple packages if
564-
there is more than one index available, but in general this should be negligible
565-
because the simple API calls are very cheap and the user should not notice any
566-
extra overhead.
567-
568-
If we are in synchronous mode, then we will use the first result that we
569-
find in case extra indexes are specified.
570-
""",
571-
default = True,
572-
),
573556
"python_version": attr.string(
574557
mandatory = True,
575558
doc = """
@@ -596,7 +579,6 @@ code will be re-evaluated when any of files in the default changes.
596579
""",
597580
),
598581
}, **ATTRS)
599-
attrs.update(AUTH_ATTRS)
600582

601583
return attrs
602584

python/private/pypi/pypi.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"pip module extensions for use with bzlmod."
1616

17+
load("//python/private:auth.bzl", "AUTH_ATTRS")
1718
load("//python/private/pypi:extension.bzl", "override_tag", "pypi_attrs", "whl_mod_attrs", _pypi = "pypi")
1819

1920
def _impl(module_ctx):
@@ -25,6 +26,7 @@ def _impl(module_ctx):
2526

2627
def _install_attrs():
2728
attrs = pypi_attrs()
29+
attrs.update(AUTH_ATTRS)
2830
attrs.update({
2931
"extra_index_urls": attr.string_list(
3032
doc = """\
@@ -70,7 +72,27 @@ The indexes must support Simple API as described here:
7072
https://packaging.python.org/en/latest/specifications/simple-repository-api/
7173
""",
7274
),
75+
"parallel_download": attr.bool(
76+
doc = """\
77+
The flag allows to make use of parallel downloading feature in bazel 7.1 and above
78+
when the bazel downloader is used. This is by default enabled as it improves the
79+
performance by a lot, but in case the queries to the simple API are very expensive
80+
or when debugging authentication issues one may want to disable this feature.
81+
82+
NOTE, This will download (potentially duplicate) data for multiple packages if
83+
there is more than one index available, but in general this should be negligible
84+
because the simple API calls are very cheap and the user should not notice any
85+
extra overhead.
86+
87+
If we are in synchronous mode, then we will use the first result that we
88+
find in case extra indexes are specified.
89+
""",
90+
default = True,
91+
),
7392
})
93+
94+
# These attributes are not used:
95+
attrs.pop("download_only")
7496
return attrs
7597

7698
pypi = module_extension(

0 commit comments

Comments
 (0)