Skip to content

Commit 1b8e82e

Browse files
committed
Add an example on how to override the URLs
1 parent 9572686 commit 1b8e82e

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

examples/bzlmod/MODULE.bazel

+11
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,20 @@ python.override(
4242
available_python_versions = [
4343
"3.10.9",
4444
"3.9.19",
45+
# Keep the following versions which are present in MINOR_MAPPING, but
46+
# are not present above
47+
"3.10.14",
4548
],
4649
)
4750
python.version_override(
51+
sha256s = {
52+
"aarch64-apple-darwin": "1409acd9a506e2d1d3b65c1488db4e40d8f19d09a7df099667c87a506f71c0ef",
53+
"aarch64-unknown-linux-gnu": "8f351a8cc348bb45c0f95b8634c8345ec6e749e483384188ad865b7428342703",
54+
"x86_64-apple-darwin": "8146ad4390710ec69b316a5649912df0247d35f4a42e2aa9615bffd87b3e235a",
55+
"x86_64-pc-windows-msvc": "a1d9a594cd3103baa24937ad9150c1a389544b4350e859200b3e5c036ac352bd",
56+
"x86_64-unknown-linux-gnu": "9b64eca2a94f7aff9409ad70bdaa7fbbf8148692662e764401883957943620dd",
57+
},
58+
url = "20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz",
4859
version = "3.10.2",
4960
)
5061

python/private/python.bzl

+6-5
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ def _fail_multiple_default_toolchains(first, second):
260260
def _process_tag_classes(mod):
261261
arg_structs = []
262262
seen_versions = {}
263-
available_versions = TOOL_VERSIONS
263+
available_versions = {}
264+
available_versions.update(TOOL_VERSIONS)
264265
base_url = DEFAULT_RELEASE_BASE_URL
265266

266267
for tag in mod.tags.toolchain:
@@ -270,7 +271,7 @@ def _process_tag_classes(mod):
270271
if mod.is_root:
271272
for tag in mod.tags.version_override:
272273
sha256 = {}
273-
for p, sha in tag.sha256.items():
274+
for p, sha in tag.sha256s.items():
274275
if p not in PLATFORMS:
275276
fail("The platform must be one of {allowed} but got '{got}'".format(
276277
allowed = sorted(PLATFORMS),
@@ -291,10 +292,10 @@ def _process_tag_classes(mod):
291292
if tag.available_python_versions:
292293
all_known_versions = sorted(available_versions)
293294
available_versions = {
294-
v: available_versions.get(v, fail("unknown version {}, known versions: {}".format(
295+
v: available_versions[v] if v in available_versions else fail("unknown version '{}', known versions are: {}".format(
295296
v,
296297
all_known_versions,
297-
)))
298+
))
298299
for v in tag.available_python_versions
299300
}
300301

@@ -433,7 +434,7 @@ _version_override = tag_class(
433434
doc = """Tag class used to override single python version settings.""",
434435
attrs = {
435436
"sha256s": attr.string_dict(
436-
mandatory = True,
437+
mandatory = False,
437438
doc = "The python platform to sha256 dict. The platform key must be present in the PLATFORMS dict.",
438439
),
439440
"strip_prefix": attr.string(

0 commit comments

Comments
 (0)