xref: /aosp_15_r20/external/bazelbuild-rules_python/tests/support/py_toolchains/BUILD (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1# Copyright 2024 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
15# ====================
16# NOTE: tests/support/support.bzl has constants to easily refer to
17# these toolchains.
18# ====================
19
20load("//python:py_runtime.bzl", "py_runtime")
21load("//python:py_runtime_pair.bzl", "py_runtime_pair")
22load("//python/private:py_exec_tools_toolchain.bzl", "py_exec_tools_toolchain")  # buildifier: disable=bzl-visibility
23
24# NOTE: A platform runtime is used because it doesn't include any files. This
25# makes it easier for analysis tests to verify content.
26py_runtime(
27    name = "platform_runtime",
28    implementation_name = "fakepy",
29    interpreter_path = "/fake/python3.9",
30    interpreter_version_info = {
31        "major": "4",
32        "minor": "5",
33    },
34)
35
36py_runtime_pair(
37    name = "platform_runtime_pair",
38    py3_runtime = ":platform_runtime",
39)
40
41toolchain(
42    name = "platform_toolchain",
43    toolchain = ":platform_runtime_pair",
44    toolchain_type = "//python:toolchain_type",
45)
46
47toolchain(
48    name = "exec_toolchain",
49    toolchain = ":exec_toolchain_impl",
50    toolchain_type = "//python:exec_tools_toolchain_type",
51)
52
53# An exec toolchain is explicitly defined so that the tests pass when run
54# in environments that aren't using the toolchains generated by the
55# hermetic runtimes.
56py_exec_tools_toolchain(
57    name = "exec_toolchain_impl",
58    precompiler = "//tools/precompiler:precompiler",
59)
60