diff options
author | Ignas Anikevicius <anikevicius@gmail.com> | 2023-06-24 05:05:25 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-23 20:05:25 +0000 |
commit | 5b8fa22a2f22501b18b4aea97c5dbfe3a6913a0c (patch) | |
tree | 3d914263ee14b253e3ded9b859c2c46994411fe4 /python/private/coverage_deps.bzl | |
parent | fe2c3256ddb51ad04d6af70e1cec59770a29596e (diff) | |
download | bazelbuild-rules_python-5b8fa22a2f22501b18b4aea97c5dbfe3a6913a0c.tar.gz |
fix(toolchain): restrict coverage tool visibility under bzlmod (#1252)
Before this PR the `coverage_tool` automatically registered by
`rules_python`
was visible outside the toolchain repository. This fixes it to be
consistent
with `non-bzlmod` setups and ensures that the default `coverage_tool` is
not
visible outside the toolchain repos.
This means that the `MODULE.bazel` file can be cleaned-up at the expense
of
relaxing the `coverage_tool` attribute for the `python_repository` to be
a
simple string as the label would be evaluated within the context of
`rules_python` which may not necessarily resolve correctly without the
`use_repo` statement in our `MODULE.bazel`.
Diffstat (limited to 'python/private/coverage_deps.bzl')
-rw-r--r-- | python/private/coverage_deps.bzl | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/python/private/coverage_deps.bzl b/python/private/coverage_deps.bzl index a4801ca..8d1e5f4 100644 --- a/python/private/coverage_deps.bzl +++ b/python/private/coverage_deps.bzl @@ -17,11 +17,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load( - "//python:versions.bzl", - "MINOR_MAPPING", - "PLATFORMS", -) # Update with './tools/update_coverage_deps.py <version>' #START: managed by update_coverage_deps.py script @@ -103,7 +98,7 @@ _coverage_deps = { _coverage_patch = Label("//python/private:coverage.patch") -def coverage_dep(name, python_version, platform, visibility, install = True): +def coverage_dep(name, python_version, platform, visibility): """Register a singe coverage dependency based on the python version and platform. Args: @@ -111,8 +106,6 @@ def coverage_dep(name, python_version, platform, visibility, install = True): python_version: The full python version. platform: The platform, which can be found in //python:versions.bzl PLATFORMS dict. visibility: The visibility of the coverage tool. - install: should we install the dependency with a given name or generate the label - of the bzlmod dependency fallback, which is hard-coded in MODULE.bazel? Returns: The label of the coverage tool if the platform is supported, otherwise - None. @@ -131,17 +124,6 @@ def coverage_dep(name, python_version, platform, visibility, install = True): # Some wheels are not present for some builds, so let's silently ignore those. return None - if not install: - # FIXME @aignas 2023-01-19: right now we use globally installed coverage - # which has visibility set to public, but is hidden due to repo remapping. - # - # The name of the toolchain is not known when registering the coverage tooling, - # so we use this as a workaround for now. - return Label("@pypi__coverage_{abi}_{platform}//:coverage".format( - abi = abi, - platform = platform, - )) - maybe( http_archive, name = name, @@ -162,26 +144,4 @@ filegroup( urls = [url], ) - return Label("@@{name}//:coverage".format(name = name)) - -def install_coverage_deps(): - """Register the dependency for the coverage dep. - - This is only used under bzlmod. - """ - - for python_version in MINOR_MAPPING.values(): - for platform in PLATFORMS.keys(): - if "windows" in platform: - continue - - coverage_dep( - name = "pypi__coverage_cp{version_no_dot}_{platform}".format( - version_no_dot = python_version.rpartition(".")[0].replace(".", ""), - platform = platform, - ), - python_version = python_version, - platform = platform, - visibility = ["//visibility:public"], - install = True, - ) + return "@{name}//:coverage".format(name = name) |