Skip to content

Commit 98f4c8a

Browse files
committed
skip local_toolchains test if before 3.9
1 parent 53f245e commit 98f4c8a

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

tests/integration/local_toolchains/BUILD.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,30 @@
1313
# limitations under the License.
1414

1515
load("@rules_python//python:py_test.bzl", "py_test")
16+
load(":defs.bzl", "toolchain_version_condition")
1617

1718
py_test(
1819
name = "test",
1920
srcs = ["test.py"],
21+
# Make this test better respect pyenv
22+
env_inherit = ["PYENV_VERSION"],
23+
# NOTE: This isn't strictly correct because is_toolchain_py39plus
24+
# ends up using the config state coming into the target, not from within
25+
# the target. There's no transitions going on, though, so it works OK.
26+
target_compatible_with = select({
27+
# Our RBE's system python is 3.6, which is too old.
28+
":is_toolchain_py39plus": [],
29+
"//conditions:default": ["@platforms//:incompatible"],
30+
}),
31+
)
32+
33+
config_setting(
34+
name = "is_toolchain_py39plus",
35+
flag_values = {
36+
":toolchain_py39plus_flag": "yes",
37+
},
38+
)
39+
40+
toolchain_version_condition(
41+
name = "toolchain_py39plus_flag",
2042
)

tests/integration/local_toolchains/MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
module(name = "module_under_test")
1515

1616
bazel_dep(name = "rules_python", version = "0.0.0")
17+
bazel_dep(name = "platforms", version = "0.0.11")
18+
1719
local_path_override(
1820
module_name = "rules_python",
1921
path = "../../..",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def _toolchain_version_condition_impl(ctx):
2+
runtime = ctx.toolchains["@rules_python//python:toolchain_type"].py_runtime
3+
version = (
4+
runtime.interpreter_version_info.major,
5+
runtime.interpreter_version_info.minor,
6+
)
7+
value = "yes" if version >= (3, 9) else "no"
8+
return [config_common.FeatureFlagInfo(value = value)]
9+
10+
toolchain_version_condition = rule(
11+
implementation = _toolchain_version_condition_impl,
12+
toolchains = ["@rules_python//python:toolchain_type"],
13+
)

tests/integration/local_toolchains/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def test_python_from_path_used(self):
4747
realpath base_exe: {os.path.realpath(sys._base_executable)}
4848
4949
from shell resolution:
50+
which python3: {shell_path=}:
5051
{shell_exe=}
5152
{shell_base_exe=}
5253
realpath exe : {os.path.realpath(shell_exe)}

0 commit comments

Comments
 (0)