xref: /aosp_15_r20/external/bazelbuild-rules_python/python/private/coverage_deps.bzl (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1*60517a1eSAndroid Build Coastguard Worker# Copyright 2023 The Bazel Authors. All rights reserved.
2*60517a1eSAndroid Build Coastguard Worker#
3*60517a1eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*60517a1eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*60517a1eSAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*60517a1eSAndroid Build Coastguard Worker#
7*60517a1eSAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
8*60517a1eSAndroid Build Coastguard Worker#
9*60517a1eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*60517a1eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*60517a1eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*60517a1eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*60517a1eSAndroid Build Coastguard Worker# limitations under the License.
14*60517a1eSAndroid Build Coastguard Worker
15*60517a1eSAndroid Build Coastguard Worker"""Dependencies for coverage.py used by the hermetic toolchain.
16*60517a1eSAndroid Build Coastguard Worker"""
17*60517a1eSAndroid Build Coastguard Worker
18*60517a1eSAndroid Build Coastguard Workerload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
19*60517a1eSAndroid Build Coastguard Workerload("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
20*60517a1eSAndroid Build Coastguard Workerload("//python/private:version_label.bzl", "version_label")
21*60517a1eSAndroid Build Coastguard Worker
22*60517a1eSAndroid Build Coastguard Worker# START: maintained by 'bazel run //tools/private/update_deps:update_coverage_deps <version>'
23*60517a1eSAndroid Build Coastguard Worker_coverage_deps = {
24*60517a1eSAndroid Build Coastguard Worker    "cp310": {
25*60517a1eSAndroid Build Coastguard Worker        "aarch64-apple-darwin": (
26*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/a3/36/b5ae380c05f58544a40ff36f87fa1d6e45f5c2f299335586aac140c341ce/coverage-7.4.3-cp310-cp310-macosx_11_0_arm64.whl",
27*60517a1eSAndroid Build Coastguard Worker            "718187eeb9849fc6cc23e0d9b092bc2348821c5e1a901c9f8975df0bc785bfd4",
28*60517a1eSAndroid Build Coastguard Worker        ),
29*60517a1eSAndroid Build Coastguard Worker        "aarch64-unknown-linux-gnu": (
30*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/9e/48/5ae1ccf4601500af0ca36eba0a2c1f1796e58fb7495de6da55ed43e13e5f/coverage-7.4.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
31*60517a1eSAndroid Build Coastguard Worker            "767b35c3a246bcb55b8044fd3a43b8cd553dd1f9f2c1eeb87a302b1f8daa0524",
32*60517a1eSAndroid Build Coastguard Worker        ),
33*60517a1eSAndroid Build Coastguard Worker        "x86_64-apple-darwin": (
34*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/50/5a/d727fcd2e0fc3aba61591b6f0fe1e87865ea9b6275f58f35810d6f85b05b/coverage-7.4.3-cp310-cp310-macosx_10_9_x86_64.whl",
35*60517a1eSAndroid Build Coastguard Worker            "8580b827d4746d47294c0e0b92854c85a92c2227927433998f0d3320ae8a71b6",
36*60517a1eSAndroid Build Coastguard Worker        ),
37*60517a1eSAndroid Build Coastguard Worker        "x86_64-unknown-linux-gnu": (
38*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/23/0a/ab5b0f6d6b24f7156624e7697ec7ab49f9d5cdac922da90d9927ae5de1cf/coverage-7.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
39*60517a1eSAndroid Build Coastguard Worker            "ba3a8aaed13770e970b3df46980cb068d1c24af1a1968b7818b69af8c4347efb",
40*60517a1eSAndroid Build Coastguard Worker        ),
41*60517a1eSAndroid Build Coastguard Worker    },
42*60517a1eSAndroid Build Coastguard Worker    "cp311": {
43*60517a1eSAndroid Build Coastguard Worker        "aarch64-apple-darwin": (
44*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/f8/a1/161102d2e26fde2d878d68cc1ed303758dc7b01ee14cc6aa70f5fd1b910d/coverage-7.4.3-cp311-cp311-macosx_11_0_arm64.whl",
45*60517a1eSAndroid Build Coastguard Worker            "489763b2d037b164846ebac0cbd368b8a4ca56385c4090807ff9fad817de4113",
46*60517a1eSAndroid Build Coastguard Worker        ),
47*60517a1eSAndroid Build Coastguard Worker        "aarch64-unknown-linux-gnu": (
48*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/a7/af/1510df1132a68ca876013c0417ca46836252e43871d2623b489e4339c980/coverage-7.4.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
49*60517a1eSAndroid Build Coastguard Worker            "451f433ad901b3bb00184d83fd83d135fb682d780b38af7944c9faeecb1e0bfe",
50*60517a1eSAndroid Build Coastguard Worker        ),
51*60517a1eSAndroid Build Coastguard Worker        "x86_64-apple-darwin": (
52*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/ca/77/f17a5b199e8ca0443ace312f7e07ff3e4e7ba7d7c52847567d6f1edb22a7/coverage-7.4.3-cp311-cp311-macosx_10_9_x86_64.whl",
53*60517a1eSAndroid Build Coastguard Worker            "cbbe5e739d45a52f3200a771c6d2c7acf89eb2524890a4a3aa1a7fa0695d2a47",
54*60517a1eSAndroid Build Coastguard Worker        ),
55*60517a1eSAndroid Build Coastguard Worker        "x86_64-unknown-linux-gnu": (
56*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/a9/1a/e2120233177b3e2ea9dcfd49a050748060166c74792b2b1db4a803307da4/coverage-7.4.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
57*60517a1eSAndroid Build Coastguard Worker            "b3ec74cfef2d985e145baae90d9b1b32f85e1741b04cd967aaf9cfa84c1334f3",
58*60517a1eSAndroid Build Coastguard Worker        ),
59*60517a1eSAndroid Build Coastguard Worker    },
60*60517a1eSAndroid Build Coastguard Worker    "cp312": {
61*60517a1eSAndroid Build Coastguard Worker        "aarch64-apple-darwin": (
62*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/9d/d8/111ec1a65fef57ad2e31445af627d481f660d4a9218ee5c774b45187812a/coverage-7.4.3-cp312-cp312-macosx_11_0_arm64.whl",
63*60517a1eSAndroid Build Coastguard Worker            "d6cdecaedea1ea9e033d8adf6a0ab11107b49571bbb9737175444cea6eb72328",
64*60517a1eSAndroid Build Coastguard Worker        ),
65*60517a1eSAndroid Build Coastguard Worker        "aarch64-unknown-linux-gnu": (
66*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/8f/eb/28416f1721a3b7fa28ea499e8a6f867e28146ea2453839c2bca04a001eeb/coverage-7.4.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
67*60517a1eSAndroid Build Coastguard Worker            "3b2eccb883368f9e972e216c7b4c7c06cabda925b5f06dde0650281cb7666a30",
68*60517a1eSAndroid Build Coastguard Worker        ),
69*60517a1eSAndroid Build Coastguard Worker        "x86_64-apple-darwin": (
70*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/11/5c/2cf3e794fa5d1eb443aa8544e2ba3837d75073eaf25a1fda64d232065609/coverage-7.4.3-cp312-cp312-macosx_10_9_x86_64.whl",
71*60517a1eSAndroid Build Coastguard Worker            "b51bfc348925e92a9bd9b2e48dad13431b57011fd1038f08316e6bf1df107d10",
72*60517a1eSAndroid Build Coastguard Worker        ),
73*60517a1eSAndroid Build Coastguard Worker        "x86_64-unknown-linux-gnu": (
74*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/2f/db/70900f10b85a66f761a3a28950ccd07757d51548b1d10157adc4b9415f15/coverage-7.4.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
75*60517a1eSAndroid Build Coastguard Worker            "b9a4a8dd3dcf4cbd3165737358e4d7dfbd9d59902ad11e3b15eebb6393b0446e",
76*60517a1eSAndroid Build Coastguard Worker        ),
77*60517a1eSAndroid Build Coastguard Worker    },
78*60517a1eSAndroid Build Coastguard Worker    "cp38": {
79*60517a1eSAndroid Build Coastguard Worker        "aarch64-apple-darwin": (
80*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/96/71/1c299b12e80d231e04a2bfd695e761fb779af7ab66f8bd3cb15649be82b3/coverage-7.4.3-cp38-cp38-macosx_11_0_arm64.whl",
81*60517a1eSAndroid Build Coastguard Worker            "280459f0a03cecbe8800786cdc23067a8fc64c0bd51dc614008d9c36e1659d7e",
82*60517a1eSAndroid Build Coastguard Worker        ),
83*60517a1eSAndroid Build Coastguard Worker        "aarch64-unknown-linux-gnu": (
84*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/c7/a7/b00eaa53d904193478eae01625d784b2af8b522a98028f47c831dcc95663/coverage-7.4.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
85*60517a1eSAndroid Build Coastguard Worker            "6c0cdedd3500e0511eac1517bf560149764b7d8e65cb800d8bf1c63ebf39edd2",
86*60517a1eSAndroid Build Coastguard Worker        ),
87*60517a1eSAndroid Build Coastguard Worker        "x86_64-apple-darwin": (
88*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/e2/bc/f54b24b476db0069ac04ff2cdeb28cd890654c8619761bf818726022c76a/coverage-7.4.3-cp38-cp38-macosx_10_9_x86_64.whl",
89*60517a1eSAndroid Build Coastguard Worker            "28ca2098939eabab044ad68850aac8f8db6bf0b29bc7f2887d05889b17346454",
90*60517a1eSAndroid Build Coastguard Worker        ),
91*60517a1eSAndroid Build Coastguard Worker        "x86_64-unknown-linux-gnu": (
92*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/d0/3a/e882caceca2c7d65791a4a759764a1bf803bbbd10caf38ec41d73a45219e/coverage-7.4.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
93*60517a1eSAndroid Build Coastguard Worker            "dec9de46a33cf2dd87a5254af095a409ea3bf952d85ad339751e7de6d962cde6",
94*60517a1eSAndroid Build Coastguard Worker        ),
95*60517a1eSAndroid Build Coastguard Worker    },
96*60517a1eSAndroid Build Coastguard Worker    "cp39": {
97*60517a1eSAndroid Build Coastguard Worker        "aarch64-apple-darwin": (
98*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/66/f2/57f5d3c9d2e78c088e4c8dbc933b85fa81c424f23641f10c1aa64052ee4f/coverage-7.4.3-cp39-cp39-macosx_11_0_arm64.whl",
99*60517a1eSAndroid Build Coastguard Worker            "77fbfc5720cceac9c200054b9fab50cb2a7d79660609200ab83f5db96162d20c",
100*60517a1eSAndroid Build Coastguard Worker        ),
101*60517a1eSAndroid Build Coastguard Worker        "aarch64-unknown-linux-gnu": (
102*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/ad/3f/cde6fd2e4cc447bd24e3dc2e79abd2e0fba67ac162996253d3505f8efef4/coverage-7.4.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
103*60517a1eSAndroid Build Coastguard Worker            "6679060424faa9c11808598504c3ab472de4531c571ab2befa32f4971835788e",
104*60517a1eSAndroid Build Coastguard Worker        ),
105*60517a1eSAndroid Build Coastguard Worker        "x86_64-apple-darwin": (
106*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/d6/cf/4094ac6410b680c91c5e55a56f25f4b3a878e2fcbf773c1cecfbdbaaec4f/coverage-7.4.3-cp39-cp39-macosx_10_9_x86_64.whl",
107*60517a1eSAndroid Build Coastguard Worker            "3b253094dbe1b431d3a4ac2f053b6d7ede2664ac559705a704f621742e034f1f",
108*60517a1eSAndroid Build Coastguard Worker        ),
109*60517a1eSAndroid Build Coastguard Worker        "x86_64-unknown-linux-gnu": (
110*60517a1eSAndroid Build Coastguard Worker            "https://files.pythonhosted.org/packages/b5/ad/effc12b8f72321cb847c5ba7f4ea7ce3e5c19c641f6418131f8fb0ab2f61/coverage-7.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
111*60517a1eSAndroid Build Coastguard Worker            "8640f1fde5e1b8e3439fe482cdc2b0bb6c329f4bb161927c28d2e8879c6029ee",
112*60517a1eSAndroid Build Coastguard Worker        ),
113*60517a1eSAndroid Build Coastguard Worker    },
114*60517a1eSAndroid Build Coastguard Worker}
115*60517a1eSAndroid Build Coastguard Worker# END: maintained by 'bazel run //tools/private/update_deps:update_coverage_deps <version>'
116*60517a1eSAndroid Build Coastguard Worker
117*60517a1eSAndroid Build Coastguard Worker_coverage_patch = Label("//python/private:coverage.patch")
118*60517a1eSAndroid Build Coastguard Worker
119*60517a1eSAndroid Build Coastguard Workerdef coverage_dep(name, python_version, platform, visibility):
120*60517a1eSAndroid Build Coastguard Worker    """Register a single coverage dependency based on the python version and platform.
121*60517a1eSAndroid Build Coastguard Worker
122*60517a1eSAndroid Build Coastguard Worker    Args:
123*60517a1eSAndroid Build Coastguard Worker        name: The name of the registered repository.
124*60517a1eSAndroid Build Coastguard Worker        python_version: The full python version.
125*60517a1eSAndroid Build Coastguard Worker        platform: The platform, which can be found in //python:versions.bzl PLATFORMS dict.
126*60517a1eSAndroid Build Coastguard Worker        visibility: The visibility of the coverage tool.
127*60517a1eSAndroid Build Coastguard Worker
128*60517a1eSAndroid Build Coastguard Worker    Returns:
129*60517a1eSAndroid Build Coastguard Worker        The label of the coverage tool if the platform is supported, otherwise - None.
130*60517a1eSAndroid Build Coastguard Worker    """
131*60517a1eSAndroid Build Coastguard Worker    if "windows" in platform:
132*60517a1eSAndroid Build Coastguard Worker        # NOTE @aignas 2023-01-19: currently we do not support windows as the
133*60517a1eSAndroid Build Coastguard Worker        # upstream coverage wrapper is written in shell. Do not log any warning
134*60517a1eSAndroid Build Coastguard Worker        # for now as it is not actionable.
135*60517a1eSAndroid Build Coastguard Worker        return None
136*60517a1eSAndroid Build Coastguard Worker
137*60517a1eSAndroid Build Coastguard Worker    abi = "cp" + version_label(python_version)
138*60517a1eSAndroid Build Coastguard Worker    url, sha256 = _coverage_deps.get(abi, {}).get(platform, (None, ""))
139*60517a1eSAndroid Build Coastguard Worker
140*60517a1eSAndroid Build Coastguard Worker    if url == None:
141*60517a1eSAndroid Build Coastguard Worker        # Some wheels are not present for some builds, so let's silently ignore those.
142*60517a1eSAndroid Build Coastguard Worker        return None
143*60517a1eSAndroid Build Coastguard Worker
144*60517a1eSAndroid Build Coastguard Worker    maybe(
145*60517a1eSAndroid Build Coastguard Worker        http_archive,
146*60517a1eSAndroid Build Coastguard Worker        name = name,
147*60517a1eSAndroid Build Coastguard Worker        build_file_content = """
148*60517a1eSAndroid Build Coastguard Workerfilegroup(
149*60517a1eSAndroid Build Coastguard Worker    name = "coverage",
150*60517a1eSAndroid Build Coastguard Worker    srcs = ["coverage/__main__.py"],
151*60517a1eSAndroid Build Coastguard Worker    data = glob(["coverage/*.py", "coverage/**/*.py", "coverage/*.so"]),
152*60517a1eSAndroid Build Coastguard Worker    visibility = {visibility},
153*60517a1eSAndroid Build Coastguard Worker)
154*60517a1eSAndroid Build Coastguard Worker    """.format(
155*60517a1eSAndroid Build Coastguard Worker            visibility = visibility,
156*60517a1eSAndroid Build Coastguard Worker        ),
157*60517a1eSAndroid Build Coastguard Worker        patch_args = ["-p1"],
158*60517a1eSAndroid Build Coastguard Worker        patches = [_coverage_patch],
159*60517a1eSAndroid Build Coastguard Worker        sha256 = sha256,
160*60517a1eSAndroid Build Coastguard Worker        type = "zip",
161*60517a1eSAndroid Build Coastguard Worker        urls = [url],
162*60517a1eSAndroid Build Coastguard Worker    )
163*60517a1eSAndroid Build Coastguard Worker
164*60517a1eSAndroid Build Coastguard Worker    return "@{name}//:coverage".format(name = name)
165