generated from bazel-contrib/rules-template
-
Notifications
You must be signed in to change notification settings - Fork 23
/
interpreter_version.bzl
39 lines (32 loc) · 1.17 KB
/
interpreter_version.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Provides a config flag that returns the micro-level version of the selected rules_python toolchain."""
load("@rules_python//python:versions.bzl", "TOOL_VERSIONS")
def _rules_python_interpreter_version_impl(ctx):
return [
config_common.FeatureFlagInfo(value = ctx.attr.version),
]
_rules_python_interpreter_version = rule(
implementation = _rules_python_interpreter_version_impl,
attrs = {
"version": attr.string(mandatory = True),
},
)
def rules_python_interpreter_version(name, default_version, **kwargs):
"""Builds a target that returns the currently-selected rules_pycross toolchain version.
This value can be used in a config_setting; e.g.,
config_setting(
name = "foo",
flag_values = {
"@rules_pycross//pycross/private:rules_python_interpreter_version": "3.12.0",
},
)
"""
selects = {
"@rules_python//python/config_settings:is_python_%s" % version: version
for version in sorted(TOOL_VERSIONS)
}
selects["//conditions:default"] = default_version
_rules_python_interpreter_version(
name = name,
version = select(selects),
**kwargs
)