Skip to content

Commit 9572686

Browse files
committed
wip
1 parent b1d5a43 commit 9572686

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

examples/bzlmod/MODULE.bazel

+11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ python.toolchain(
3737
python_version = "3.10",
3838
)
3939

40+
# One can override the actual toolchain versions that are available
41+
python.override(
42+
available_python_versions = [
43+
"3.10.9",
44+
"3.9.19",
45+
],
46+
)
47+
python.version_override(
48+
version = "3.10.2",
49+
)
50+
4051
# You only need to load this repositories if you are using multiple Python versions.
4152
# See the tests folder for various examples on using multiple Python versions.
4253
# The names "python_3_9" and "python_3_10" are autmatically created by the repo

python/private/python.bzl

+6-1
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,20 @@ def _process_tag_classes(mod):
289289
for tag in mod.tags.override:
290290
base_url = tag.base_url
291291
if tag.available_python_versions:
292+
all_known_versions = sorted(available_versions)
292293
available_versions = {
293-
v: available_versions[v]
294+
v: available_versions.get(v, fail("unknown version {}, known versions: {}".format(
295+
v,
296+
all_known_versions,
297+
)))
294298
for v in tag.available_python_versions
295299
}
296300

297301
if tag.register_all_versions and mod.name != "rules_python":
298302
fail("This override can only be used by 'rules_python'")
299303
elif tag.register_all_versions:
300304
register_all = True
305+
301306
break
302307

303308
if register_all:

0 commit comments

Comments
 (0)