File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed
tests/integration/local_toolchains Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515load ("@rules_python//python:py_test.bzl" , "py_test" )
16+ load (":defs.bzl" , "toolchain_version_condition" )
1617
1718py_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)
Original file line number Diff line number Diff line change 1414module (name = "module_under_test" )
1515
1616bazel_dep (name = "rules_python" , version = "0.0.0" )
17+ bazel_dep (name = "platforms" , version = "0.0.11" )
18+
1719local_path_override (
1820 module_name = "rules_python" ,
1921 path = "../../.." ,
Original file line number Diff line number Diff line change 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+ )
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ def test_python_from_path_used(self):
4747realpath base_exe: { os .path .realpath (sys ._base_executable )}
4848
4949from shell resolution:
50+ which python3: { shell_path = } :
5051{ shell_exe = }
5152{ shell_base_exe = }
5253realpath exe : { os .path .realpath (shell_exe )}
You can’t perform that action at this time.
0 commit comments