Skip to content

Commit 13f8a30

Browse files
committed
add a better failure message and add compatibility aliases
1 parent 9b4a71a commit 13f8a30

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

python/private/config_settings.bzl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def construct_config_settings(*, name, default_version, versions, minor_mapping,
6868
visibility = ["//visibility:public"],
6969
)
7070

71-
_reverse_minor_mapping = {full: minor for minor, full in minor_mapping.items()}
71+
_reverse_minor_mapping = {full: minor for minor, full in minor_mapping.items() if full}
7272
for version in versions:
7373
minor_version = _reverse_minor_mapping.get(version)
7474
if not minor_version:
@@ -109,12 +109,19 @@ def construct_config_settings(*, name, default_version, versions, minor_mapping,
109109
# It's private because matching the concept of e.g. "3.8" value is done
110110
# using the `is_python_X.Y` config setting group, which is aware of the
111111
# minor versions that could match instead.
112-
for minor in minor_mapping.keys():
113-
native.config_setting(
114-
name = "is_python_{}".format(minor),
115-
flag_values = {_PYTHON_VERSION_MAJOR_MINOR_FLAG: minor},
116-
visibility = ["//visibility:public"],
117-
)
112+
for minor, version in minor_mapping.items():
113+
if version:
114+
native.config_setting(
115+
name = "is_python_{}".format(minor),
116+
flag_values = {_PYTHON_VERSION_MAJOR_MINOR_FLAG: minor},
117+
visibility = ["//visibility:public"],
118+
)
119+
else:
120+
native.alias(
121+
name = "is_python_{}".format(minor),
122+
actual = "@platforms//:incompatible",
123+
visibility = ["//visibility:public"],
124+
)
118125

119126
_current_config(
120127
name = "current_config",

python/private/full_version.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def full_version(*, version, minor_mapping):
2626
major version then we return it as is.
2727
"""
2828
if version in minor_mapping:
29+
if not minor_mapping[version]:
30+
fail("Please upgrade to the next version, '{}' is no longer supported".format(version))
31+
2932
return minor_mapping[version]
3033

3134
parts = version.split(".")

python/versions.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ TOOL_VERSIONS = {
10001000

10011001
# buildifier: disable=unsorted-dict-items
10021002
MINOR_MAPPING = {
1003+
"3.8": "",
10031004
"3.9": "3.9.24",
10041005
"3.10": "3.10.19",
10051006
"3.11": "3.11.14",

0 commit comments

Comments
 (0)