aboutsummaryrefslogtreecommitdiff
path: root/python/extensions/pip.bzl
diff options
context:
space:
mode:
Diffstat (limited to 'python/extensions/pip.bzl')
-rw-r--r--python/extensions/pip.bzl46
1 files changed, 20 insertions, 26 deletions
diff --git a/python/extensions/pip.bzl b/python/extensions/pip.bzl
index add69a4..3ba0d3e 100644
--- a/python/extensions/pip.bzl
+++ b/python/extensions/pip.bzl
@@ -15,9 +15,9 @@
"pip module extension for use with bzlmod"
load("@pythons_hub//:interpreters.bzl", "DEFAULT_PYTHON_VERSION", "INTERPRETER_LABELS")
-load("@rules_python//python:pip.bzl", "whl_library_alias")
+load("//python:pip.bzl", "whl_library_alias")
load(
- "@rules_python//python/pip_install:pip_repository.bzl",
+ "//python/pip_install:pip_repository.bzl",
"locked_requirements_label",
"pip_hub_repository_bzlmod",
"pip_repository_attrs",
@@ -25,7 +25,7 @@ load(
"use_isolated",
"whl_library",
)
-load("@rules_python//python/pip_install:requirements_parser.bzl", parse_requirements = "parse")
+load("//python/pip_install:requirements_parser.bzl", parse_requirements = "parse")
load("//python/private:normalize_name.bzl", "normalize_name")
load("//python/private:version_label.bzl", "version_label")
@@ -296,15 +296,10 @@ def _pip_impl(module_ctx):
for hub_name, whl_map in hub_whl_map.items():
for whl_name, version_map in whl_map.items():
- if DEFAULT_PYTHON_VERSION not in version_map:
- fail((
- "Default python version '{version}' missing in pip " +
- "hub '{hub}': update your pip.parse() calls so that " +
- 'includes `python_version = "{version}"`'
- ).format(
- version = DEFAULT_PYTHON_VERSION,
- hub = hub_name,
- ))
+ if DEFAULT_PYTHON_VERSION in version_map:
+ whl_default_version = DEFAULT_PYTHON_VERSION
+ else:
+ whl_default_version = None
# Create the alias repositories which contains different select
# statements These select statements point to the different pip
@@ -312,7 +307,7 @@ def _pip_impl(module_ctx):
whl_library_alias(
name = hub_name + "_" + whl_name,
wheel_name = whl_name,
- default_version = DEFAULT_PYTHON_VERSION,
+ default_version = whl_default_version,
version_map = version_map,
)
@@ -348,23 +343,22 @@ Targets from different hubs should not be used together.
""",
),
"python_version": attr.string(
- default = DEFAULT_PYTHON_VERSION,
+ mandatory = True,
doc = """
-The Python version to use for resolving the pip dependencies. If not specified,
-then the default Python version (as set by the root module or rules_python)
-will be used.
+The Python version to use for resolving the pip dependencies, in Major.Minor
+format (e.g. "3.11"). Patch level granularity (e.g. "3.11.1") is not supported.
+If not specified, then the default Python version (as set by the root module or
+rules_python) will be used.
The version specified here must have a corresponding `python.toolchain()`
-configured. This attribute defaults to the version of the toolchain
-that is set as the default Python version. Or if only one toolchain
-is used, this attribute defaults to that version of Python.
+configured.
""",
),
"whl_modifications": attr.label_keyed_string_dict(
mandatory = False,
doc = """\
A dict of labels to wheel names that is typically generated by the whl_modifications.
-The labels are JSON config files describing the modifications.
+The labels are JSON config files describing the modifications.
""",
),
}, **pip_repository_attrs)
@@ -397,7 +391,7 @@ executable.""",
),
"copy_files": attr.string_dict(
doc = """\
-(dict, optional): A mapping of `src` and `out` files for
+(dict, optional): A mapping of `src` and `out` files for
[@bazel_skylib//rules:copy_file.bzl][cf]""",
),
"data": attr.string_list(
@@ -458,10 +452,10 @@ the BUILD files for wheels.
attrs = _pip_parse_ext_attrs(),
doc = """\
This tag class is used to create a pip hub and all of the spokes that are part of that hub.
-This tag class reuses most of the pip attributes that are found in
+This tag class reuses most of the pip attributes that are found in
@rules_python//python/pip_install:pip_repository.bzl.
-The exceptions are it does not use the args 'repo_prefix',
-and 'incompatible_generate_aliases'. We set the repository prefix
+The exceptions are it does not use the args 'repo_prefix',
+and 'incompatible_generate_aliases'. We set the repository prefix
for the user and the alias arg is always True in bzlmod.
""",
),
@@ -485,7 +479,7 @@ def _whl_mods_repo_impl(rctx):
_whl_mods_repo = repository_rule(
doc = """\
-This rule creates json files based on the whl_mods attribute.
+This rule creates json files based on the whl_mods attribute.
""",
implementation = _whl_mods_repo_impl,
attrs = {