xref: /aosp_15_r20/external/bazelbuild-rules_python/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1# Copyright 2017 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
15load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
16load(":version.bzl", "BAZEL_VERSION")
17
18package(default_visibility = ["//visibility:public"])
19
20licenses(["notice"])
21
22exports_files([
23    "LICENSE",
24    "version.bzl",
25])
26
27exports_files(
28    glob(["*.md"]),
29    visibility = ["//docs:__subpackages__"],
30)
31
32filegroup(
33    name = "distribution",
34    srcs = [
35        "BUILD.bazel",
36        "MODULE.bazel",
37        "WORKSPACE",
38        "WORKSPACE.bzlmod",
39        "internal_deps.bzl",
40        "internal_setup.bzl",
41        "version.bzl",
42        "//python:distribution",
43        "//tools:distribution",
44        "@rules_python_gazelle_plugin//:distribution",
45    ],
46    visibility = [
47        "//:__subpackages__",
48    ],
49)
50
51bzl_library(
52    name = "version_bzl",
53    srcs = ["version.bzl"],
54    visibility = ["//:__subpackages__"],
55)
56
57# Reexport of all bzl files used to allow downstream rules to generate docs
58# without shipping with a dependency on Skylib
59filegroup(
60    name = "bzl",
61    srcs = [
62        "//python/pip_install:bzl",
63        "//python:bzl",
64        # Requires Bazel 0.29 onward for public visibility of these .bzl files.
65        "@bazel_tools//tools/python:python_version.bzl",
66        "@bazel_tools//tools/python:srcs_version.bzl",
67        "@bazel_tools//tools/python:toolchain.bzl",
68        "@bazel_tools//tools/python:utils.bzl",
69    ],
70    visibility = ["//visibility:public"],
71)
72
73genrule(
74    name = "assert_bazelversion",
75    srcs = [".bazelversion"],
76    outs = ["assert_bazelversion_test.sh"],
77    cmd = """\
78set -o errexit -o nounset -o pipefail
79current=$$(cat "$(execpath .bazelversion)")
80cat > "$@" <<EOF
81#!/usr/bin/env bash
82set -o errexit -o nounset -o pipefail
83if [[ \"$${{current}}\" != \"{expected}\" ]]; then
84    >&2 echo "ERROR: current bazel version '$${{current}}' is not the expected '{expected}'"
85    exit 1
86fi
87EOF
88""".format(
89        expected = BAZEL_VERSION,
90    ),
91    executable = True,
92)
93
94sh_test(
95    name = "assert_bazelversion_test",
96    srcs = [":assert_bazelversion_test.sh"],
97)
98