Skip to content

Commit

Permalink
fixup: Simplify the supported coverage binary lookup
Browse files Browse the repository at this point in the history
Now we store everything in a nested dict of tuples, which makes the
lookup of supported versions slightly cleaner.
  • Loading branch information
aignas committed Jan 19, 2023
1 parent bd9f97e commit f9ea7da
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 110 deletions.
177 changes: 74 additions & 103 deletions python/private/coverage_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,98 +11,76 @@ load(

# Update with './tools/update_coverage_deps.py <version>'
#START: managed by update_coverage_deps.py script
_coverage_deps = [
(
"cp310",
"https://files.pythonhosted.org/packages/89/a2/cbf599e50bb4be416e0408c4cf523c354c51d7da39935461a9687e039481/coverage-6.5.0-cp310-cp310-macosx_11_0_arm64.whl",
"784f53ebc9f3fd0e2a3f6a78b2be1bd1f5575d7863e10c6e12504f240fd06660",
"aarch64-apple-darwin",
),
(
"cp310",
"https://files.pythonhosted.org/packages/15/b0/3639d84ee8a900da0cf6450ab46e22517e4688b6cec0ba8ab6f8166103a2/coverage-6.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"b4a5be1748d538a710f87542f22c2cad22f80545a847ad91ce45e77417293eb4",
"aarch64-unknown-linux-gnu",
),
(
"cp310",
"https://files.pythonhosted.org/packages/c4/8d/5ec7d08f4601d2d792563fe31db5e9322c306848fec1e65ec8885927f739/coverage-6.5.0-cp310-cp310-macosx_10_9_x86_64.whl",
"ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53",
"x86_64-apple-darwin",
),
(
"cp310",
"https://files.pythonhosted.org/packages/3c/7d/d5211ea782b193ab8064b06dc0cc042cf1a4ca9c93a530071459172c550f/coverage-6.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"af4fffaffc4067232253715065e30c5a7ec6faac36f8fc8d6f64263b15f74db0",
"x86_64-unknown-linux-gnu",
),
(
"cp311",
"https://files.pythonhosted.org/packages/36/f3/5cbd79cf4cd059c80b59104aca33b8d05af4ad5bf5b1547645ecee716378/coverage-6.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"c4ed2820d919351f4167e52425e096af41bfabacb1857186c1ea32ff9983ed75",
"aarch64-unknown-linux-gnu",
),
(
"cp311",
"https://files.pythonhosted.org/packages/50/cf/455930004231fa87efe8be06d13512f34e070ddfee8b8bf5a050cdc47ab3/coverage-6.5.0-cp311-cp311-macosx_10_9_x86_64.whl",
"4a5375e28c5191ac38cca59b38edd33ef4cc914732c916f2929029b4bfb50795",
"x86_64-apple-darwin",
),
(
"cp311",
"https://files.pythonhosted.org/packages/6a/63/8e82513b7e4a1b8d887b4e85c1c2b6c9b754a581b187c0b084f3330ac479/coverage-6.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"a8fb6cf131ac4070c9c5a3e21de0f7dc5a0fbe8bc77c9456ced896c12fcdad91",
"x86_64-unknown-linux-gnu",
),
(
"cp38",
"https://files.pythonhosted.org/packages/07/82/79fa21ceca9a9b091eb3c67e27eb648dade27b2c9e1eb23af47232a2a365/coverage-6.5.0-cp38-cp38-macosx_11_0_arm64.whl",
"2198ea6fc548de52adc826f62cb18554caedfb1d26548c1b7c88d8f7faa8f6ba",
"aarch64-apple-darwin",
),
(
"cp38",
"https://files.pythonhosted.org/packages/40/3b/cd68cb278c4966df00158811ec1e357b9a7d132790c240fc65da57e10013/coverage-6.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"6c4459b3de97b75e3bd6b7d4b7f0db13f17f504f3d13e2a7c623786289dd670e",
"aarch64-unknown-linux-gnu",
),
(
"cp38",
"https://files.pythonhosted.org/packages/05/63/a789b462075395d34f8152229dccf92b25ca73eac05b3f6cd75fa5017095/coverage-6.5.0-cp38-cp38-macosx_10_9_x86_64.whl",
"d900bb429fdfd7f511f868cedd03a6bbb142f3f9118c09b99ef8dc9bf9643c3c",
"x86_64-apple-darwin",
),
(
"cp38",
"https://files.pythonhosted.org/packages/bd/a0/e263b115808226fdb2658f1887808c06ac3f1b579ef5dda02309e0d54459/coverage-6.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"6b07130585d54fe8dff3d97b93b0e20290de974dc8177c320aeaf23459219c0b",
"x86_64-unknown-linux-gnu",
),
(
"cp39",
"https://files.pythonhosted.org/packages/63/e9/f23e8664ec4032d7802a1cf920853196bcbdce7b56408e3efe1b2da08f3c/coverage-6.5.0-cp39-cp39-macosx_11_0_arm64.whl",
"95203854f974e07af96358c0b261f1048d8e1083f2de9b1c565e1be4a3a48cfc",
"aarch64-apple-darwin",
),
(
"cp39",
"https://files.pythonhosted.org/packages/18/95/27f80dcd8273171b781a19d109aeaed7f13d78ef6d1e2f7134a5826fd1b4/coverage-6.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"b9023e237f4c02ff739581ef35969c3739445fb059b060ca51771e69101efffe",
"aarch64-unknown-linux-gnu",
),
(
"cp39",
"https://files.pythonhosted.org/packages/ea/52/c08080405329326a7ff16c0dfdb4feefaa8edd7446413df67386fe1bbfe0/coverage-6.5.0-cp39-cp39-macosx_10_9_x86_64.whl",
"633713d70ad6bfc49b34ead4060531658dc6dfc9b3eb7d8a716d5873377ab745",
"x86_64-apple-darwin",
),
(
"cp39",
"https://files.pythonhosted.org/packages/6b/f2/919f0fdc93d3991ca074894402074d847be8ac1e1d78e7e9e1c371b69a6f/coverage-6.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"8f830ed581b45b82451a40faabb89c84e1a998124ee4212d440e9c6cf70083e5",
"x86_64-unknown-linux-gnu",
),
]
_coverage_deps = {
"cp310": {
"aarch64-apple-darwin": (
"https://files.pythonhosted.org/packages/89/a2/cbf599e50bb4be416e0408c4cf523c354c51d7da39935461a9687e039481/coverage-6.5.0-cp310-cp310-macosx_11_0_arm64.whl",
"784f53ebc9f3fd0e2a3f6a78b2be1bd1f5575d7863e10c6e12504f240fd06660",
),
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/15/b0/3639d84ee8a900da0cf6450ab46e22517e4688b6cec0ba8ab6f8166103a2/coverage-6.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"b4a5be1748d538a710f87542f22c2cad22f80545a847ad91ce45e77417293eb4",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/c4/8d/5ec7d08f4601d2d792563fe31db5e9322c306848fec1e65ec8885927f739/coverage-6.5.0-cp310-cp310-macosx_10_9_x86_64.whl",
"ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/3c/7d/d5211ea782b193ab8064b06dc0cc042cf1a4ca9c93a530071459172c550f/coverage-6.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"af4fffaffc4067232253715065e30c5a7ec6faac36f8fc8d6f64263b15f74db0",
),
},
"cp311": {
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/36/f3/5cbd79cf4cd059c80b59104aca33b8d05af4ad5bf5b1547645ecee716378/coverage-6.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"c4ed2820d919351f4167e52425e096af41bfabacb1857186c1ea32ff9983ed75",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/50/cf/455930004231fa87efe8be06d13512f34e070ddfee8b8bf5a050cdc47ab3/coverage-6.5.0-cp311-cp311-macosx_10_9_x86_64.whl",
"4a5375e28c5191ac38cca59b38edd33ef4cc914732c916f2929029b4bfb50795",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/6a/63/8e82513b7e4a1b8d887b4e85c1c2b6c9b754a581b187c0b084f3330ac479/coverage-6.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"a8fb6cf131ac4070c9c5a3e21de0f7dc5a0fbe8bc77c9456ced896c12fcdad91",
),
},
"cp38": {
"aarch64-apple-darwin": (
"https://files.pythonhosted.org/packages/07/82/79fa21ceca9a9b091eb3c67e27eb648dade27b2c9e1eb23af47232a2a365/coverage-6.5.0-cp38-cp38-macosx_11_0_arm64.whl",
"2198ea6fc548de52adc826f62cb18554caedfb1d26548c1b7c88d8f7faa8f6ba",
),
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/40/3b/cd68cb278c4966df00158811ec1e357b9a7d132790c240fc65da57e10013/coverage-6.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"6c4459b3de97b75e3bd6b7d4b7f0db13f17f504f3d13e2a7c623786289dd670e",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/05/63/a789b462075395d34f8152229dccf92b25ca73eac05b3f6cd75fa5017095/coverage-6.5.0-cp38-cp38-macosx_10_9_x86_64.whl",
"d900bb429fdfd7f511f868cedd03a6bbb142f3f9118c09b99ef8dc9bf9643c3c",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/bd/a0/e263b115808226fdb2658f1887808c06ac3f1b579ef5dda02309e0d54459/coverage-6.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"6b07130585d54fe8dff3d97b93b0e20290de974dc8177c320aeaf23459219c0b",
),
},
"cp39": {
"aarch64-apple-darwin": (
"https://files.pythonhosted.org/packages/63/e9/f23e8664ec4032d7802a1cf920853196bcbdce7b56408e3efe1b2da08f3c/coverage-6.5.0-cp39-cp39-macosx_11_0_arm64.whl",
"95203854f974e07af96358c0b261f1048d8e1083f2de9b1c565e1be4a3a48cfc",
),
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/18/95/27f80dcd8273171b781a19d109aeaed7f13d78ef6d1e2f7134a5826fd1b4/coverage-6.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"b9023e237f4c02ff739581ef35969c3739445fb059b060ca51771e69101efffe",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/ea/52/c08080405329326a7ff16c0dfdb4feefaa8edd7446413df67386fe1bbfe0/coverage-6.5.0-cp39-cp39-macosx_10_9_x86_64.whl",
"633713d70ad6bfc49b34ead4060531658dc6dfc9b3eb7d8a716d5873377ab745",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/6b/f2/919f0fdc93d3991ca074894402074d847be8ac1e1d78e7e9e1c371b69a6f/coverage-6.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"8f830ed581b45b82451a40faabb89c84e1a998124ee4212d440e9c6cf70083e5",
),
},
}
#END: managed by update_coverage_deps.py script

def coverage_dep(name, python_version, platform, visibility, install = True):
Expand All @@ -127,16 +105,9 @@ def coverage_dep(name, python_version, platform, visibility, install = True):

python_short_version = python_version.rpartition(".")[0]
abi = python_short_version.replace("3.", "cp3")
meta = None
for supported_abi, url, sha256, supported_platform in _coverage_deps:
if supported_abi == abi and supported_platform == platform:
meta = struct(
url = url,
sha256 = sha256,
)
break
url, sha256 = _coverage_deps.get(abi, {}).get(platform, (None, ""))

if meta == None:
if url == None:
# Some wheels are not present for some builds, so let's silently ignore those.
return None

Expand Down Expand Up @@ -164,9 +135,9 @@ filegroup(
""".format(
visibility = visibility,
),
sha256 = meta.sha256,
sha256 = sha256,
type = "zip",
urls = [meta.url],
urls = [url],
)

return Label("@@{name}//:coverage".format(name = name))
Expand Down
20 changes: 13 additions & 7 deletions tools/update_coverage_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pathlib
import sys
import textwrap
from collections import defaultdict
from dataclasses import dataclass
from typing import Any
from urllib import request
Expand Down Expand Up @@ -42,10 +43,8 @@ def __repr__(self):
return "\n".join(
[
"(",
f' "{self.python}",',
f' "{self.url}",',
f' "{self.sha256}",',
f' "{self.platform}",',
")",
]
)
Expand All @@ -56,11 +55,18 @@ class Deps:
deps: list[Dep]

def __repr__(self):
inner = textwrap.indent(
",\n".join([f"{repr(d)}" for d in self.deps]),
prefix=" ",
)
return "[\n{},\n]".format(inner)
deps = defaultdict(dict)
for d in self.deps:
deps[d.python][d.platform] = d

parts = []
for python, contents in deps.items():
inner = textwrap.indent(
"\n".join([f'"{platform}": {d},' for platform, d in contents.items()]),
prefix=" ",
)
parts.append('"{}": {{\n{}\n}},'.format(python, inner))
return "{{\n{}\n}}".format(textwrap.indent("\n".join(parts), prefix=" "))


def _get_platforms(filename: str, name: str, version: str, python_version: str):
Expand Down

0 comments on commit f9ea7da

Please sign in to comment.