-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use rules_python's py_runtime in generated toolchains (#1604)
This makes rules_python compatible with disabling using the native rules in Bazel. While we're here, update some examples in docs to load py_runtime to better make clear the builtin py_runtime objects shouldn't be used. Work towards #1069
- Loading branch information
Showing
8 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
load(":multi_version_tests.bzl", "multi_version_test_suite") | ||
load(":py_args_tests.bzl", "py_args_test_suite") | ||
|
||
py_args_test_suite(name = "py_args_tests") | ||
|
||
multi_version_test_suite(name = "multi_version_tests") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Tests for py_test.""" | ||
|
||
load("@rules_testing//lib:analysis_test.bzl", "analysis_test") | ||
load("@rules_testing//lib:test_suite.bzl", "test_suite") | ||
load("@rules_testing//lib:util.bzl", rt_util = "util") | ||
load("//python:versions.bzl", "TOOL_VERSIONS") | ||
load("//python/config_settings:transition.bzl", py_binary_transitioned = "py_binary", py_test_transitioned = "py_test") | ||
|
||
_tests = [] | ||
|
||
def _test_py_test_with_transition(name): | ||
rt_util.helper_target( | ||
py_test_transitioned, | ||
name = name + "_subject", | ||
srcs = [name + "_subject.py"], | ||
python_version = TOOL_VERSIONS.keys()[0], | ||
) | ||
|
||
analysis_test( | ||
name = name, | ||
target = name + "_subject", | ||
impl = _test_py_test_with_transition_impl, | ||
) | ||
|
||
def _test_py_test_with_transition_impl(env, target): | ||
# Nothing to assert; we just want to make sure it builds | ||
_ = env, target # @unused | ||
|
||
_tests.append(_test_py_test_with_transition) | ||
|
||
def _test_py_binary_with_transition(name): | ||
rt_util.helper_target( | ||
py_binary_transitioned, | ||
name = name + "_subject", | ||
srcs = [name + "_subject.py"], | ||
python_version = TOOL_VERSIONS.keys()[0], | ||
) | ||
|
||
analysis_test( | ||
name = name, | ||
target = name + "_subject", | ||
impl = _test_py_binary_with_transition_impl, | ||
) | ||
|
||
def _test_py_binary_with_transition_impl(env, target): | ||
# Nothing to assert; we just want to make sure it builds | ||
_ = env, target # @unused | ||
|
||
_tests.append(_test_py_binary_with_transition) | ||
|
||
def multi_version_test_suite(name): | ||
test_suite( | ||
name = name, | ||
tests = _tests, | ||
) |