• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Code that support testing of rules_python code."""
15
16# NOTE: Explicit Label() calls are required so that it resolves in @rules_python
17# context instead of e.g. the @rules_testing context.
18# NOTE: Some labels require str() around Label() because they are passed onto
19# rules_testing or as config_setting values, which don't support Label in some
20# places.
21
22load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER")  # buildifier: disable=bzl-visibility
23
24MAC = Label("//tests/support:mac")
25MAC_X86_64 = Label("//tests/support:mac_x86_64")
26LINUX = Label("//tests/support:linux")
27LINUX_X86_64 = Label("//tests/support:linux_x86_64")
28WINDOWS = Label("//tests/support:windows")
29WINDOWS_X86_64 = Label("//tests/support:windows_x86_64")
30
31PY_TOOLCHAINS = str(Label("//tests/support/py_toolchains:all"))
32CC_TOOLCHAIN = str(Label("//tests/support/cc_toolchains:all"))
33CROSSTOOL_TOP = Label("//tests/support/cc_toolchains:cc_toolchain_suite")
34
35# str() around Label() is necessary because rules_testing's config_settings
36# doesn't accept yet Label objects.
37ADD_SRCS_TO_RUNFILES = str(Label("//python/config_settings:add_srcs_to_runfiles"))
38EXEC_TOOLS_TOOLCHAIN = str(Label("//python/config_settings:exec_tools_toolchain"))
39PRECOMPILE = str(Label("//python/config_settings:precompile"))
40PRECOMPILE_SOURCE_RETENTION = str(Label("//python/config_settings:precompile_source_retention"))
41PYC_COLLECTION = str(Label("//python/config_settings:pyc_collection"))
42PYTHON_VERSION = str(Label("//python/config_settings:python_version"))
43VISIBLE_FOR_TESTING = str(Label("//python/private:visible_for_testing"))
44
45SUPPORTS_BOOTSTRAP_SCRIPT = select({
46    "@platforms//os:windows": ["@platforms//:incompatible"],
47    "//conditions:default": [],
48}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
49