Skip to content

Commit

Permalink
comment: address comments and set the internal pip extension to use P…
Browse files Browse the repository at this point in the history
…yPI by default
  • Loading branch information
aignas committed Jun 3, 2024
1 parent 9d35b35 commit 3fd6821
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
5 changes: 0 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ register_toolchains("@pythons_hub//:all")

pip = use_extension("//python/private/bzlmod:pip.bzl", "pip_internal")
pip.parse(
experimental_index_url = "https://pypi.org/simple",
hub_name = "rules_python_publish_deps",
python_version = "3.11",
requirements_by_platform = {
Expand All @@ -85,8 +84,6 @@ dev_pip = use_extension(
dev_dependency = True,
)
dev_pip.parse(
envsubst = ["PIP_INDEX_URL"],
experimental_index_url = "${PIP_INDEX_URL:-https://pypi.org/simple}",
experimental_requirement_cycles = {
"sphinx": [
"sphinx",
Expand All @@ -102,8 +99,6 @@ dev_pip.parse(
requirements_lock = "//docs/sphinx:requirements.txt",
)
dev_pip.parse(
envsubst = ["PIP_INDEX_URL"],
experimental_index_url = "${PIP_INDEX_URL:-https://pypi.org/simple}",
hub_name = "pypiserver",
python_version = "3.11",
requirements_lock = "//examples/wheel:requirements_server.txt",
Expand Down
24 changes: 17 additions & 7 deletions python/private/bzlmod/pip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,20 @@ def _pip_impl(module_ctx):
def _pip_non_reproducible(module_ctx):
_pip_impl(module_ctx)

if bazel_features.external_deps.extension_metadata_has_reproducible:
# We allow for calling the PyPI index and that will go into the MODULE.bazel.lock file
return module_ctx.extension_metadata(reproducible = False)
else:
return None
# We default to calling the PyPI index and that will go into the
# MODULE.bazel.lock file, hence return nothing here.
return None

def _pip_parse_ext_attrs():
def _pip_parse_ext_attrs(**kwargs):
"""Get the attributes for the pip extension.
Args:
**kwargs: A kwarg for setting defaults for the specific attributes. The
key is expected to be the same as the attribute key.
Returns:
A dict of attributes.
"""
attrs = dict({
"experimental_extra_index_urls": attr.string_list(
doc = """\
Expand All @@ -503,6 +510,7 @@ This is equivalent to `--extra-index-urls` `pip` option.
default = [],
),
"experimental_index_url": attr.string(
default = kwargs.get("experimental_index_url", ""),
doc = """\
The index URL to use for downloading wheels using bazel downloader. This value is going
to be subject to `envsubst` substitutions if necessary.
Expand Down Expand Up @@ -757,7 +765,9 @@ the BUILD files for wheels.
tag_classes = {
"override": _override_tag,
"parse": tag_class(
attrs = _pip_parse_ext_attrs(),
attrs = _pip_parse_ext_attrs(
experimental_index_url = "https://pypi.org/simple",
),
doc = """\
This tag class is used to create a pypi hub and all of the spokes that are part of that hub.
This tag class reuses most of the pypi attributes that are found in
Expand Down

0 comments on commit 3fd6821

Please sign in to comment.