|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -"Module extensions for use with bzlmod" |
| 15 | +"pip module extension for use with bzlmod" |
16 | 16 |
|
17 | | -load("@rules_python//python:repositories.bzl", "python_register_toolchains") |
18 | 17 | load("@rules_python//python/pip_install:pip_repository.bzl", "locked_requirements_label", "pip_repository_attrs", "pip_repository_bzlmod", "use_isolated", "whl_library") |
19 | | -load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies") |
20 | 18 | load("@rules_python//python/pip_install:requirements_parser.bzl", parse_requirements = "parse") |
21 | | -load("@rules_python//python/private:coverage_deps.bzl", "install_coverage_deps") |
22 | | -load("@rules_python//python/private:interpreter_hub.bzl", "hub_repo") |
23 | | - |
24 | | -def _python_impl(module_ctx): |
25 | | - toolchains = [] |
26 | | - for mod in module_ctx.modules: |
27 | | - for toolchain_attr in mod.tags.toolchain: |
28 | | - python_register_toolchains( |
29 | | - name = toolchain_attr.name, |
30 | | - python_version = toolchain_attr.python_version, |
31 | | - bzlmod = True, |
32 | | - # Toolchain registration in bzlmod is done in MODULE file |
33 | | - register_toolchains = False, |
34 | | - register_coverage_tool = toolchain_attr.configure_coverage_tool, |
35 | | - ignore_root_user_error = toolchain_attr.ignore_root_user_error, |
36 | | - ) |
37 | | - |
38 | | - # We collect all of the toolchain names to create |
39 | | - # the INTERPRETER_LABELS map. This is used |
40 | | - # by interpreter_extensions.bzl |
41 | | - toolchains.append(toolchain_attr.name) |
42 | | - |
43 | | - hub_repo( |
44 | | - name = "pythons_hub", |
45 | | - toolchains = toolchains, |
46 | | - ) |
47 | | - |
48 | | -python = module_extension( |
49 | | - implementation = _python_impl, |
50 | | - tag_classes = { |
51 | | - "toolchain": tag_class( |
52 | | - attrs = { |
53 | | - "configure_coverage_tool": attr.bool( |
54 | | - mandatory = False, |
55 | | - doc = "Whether or not to configure the default coverage tool for the toolchains.", |
56 | | - ), |
57 | | - "ignore_root_user_error": attr.bool( |
58 | | - default = False, |
59 | | - doc = "Whether the check for root should be ignored or not. This causes cache misses with .pyc files.", |
60 | | - mandatory = False, |
61 | | - ), |
62 | | - "name": attr.string(mandatory = True), |
63 | | - "python_version": attr.string(mandatory = True), |
64 | | - }, |
65 | | - ), |
66 | | - }, |
67 | | -) |
68 | | - |
69 | | -# buildifier: disable=unused-variable |
70 | | -def _internal_deps_impl(module_ctx): |
71 | | - pip_install_dependencies() |
72 | | - install_coverage_deps() |
73 | | - |
74 | | -internal_deps = module_extension( |
75 | | - implementation = _internal_deps_impl, |
76 | | - tag_classes = { |
77 | | - "install": tag_class(attrs = dict()), |
78 | | - }, |
79 | | -) |
80 | 19 |
|
81 | 20 | def _pip_impl(module_ctx): |
82 | 21 | for mod in module_ctx.modules: |
@@ -134,6 +73,10 @@ def _pip_parse_ext_attrs(): |
134 | 73 | return attrs |
135 | 74 |
|
136 | 75 | pip = module_extension( |
| 76 | + doc = """\ |
| 77 | +This extension is used to create a pip respository and create the various wheel libaries if |
| 78 | +provided in a requirements file. |
| 79 | +""", |
137 | 80 | implementation = _pip_impl, |
138 | 81 | tag_classes = { |
139 | 82 | "parse": tag_class(attrs = _pip_parse_ext_attrs()), |
|
0 commit comments