xref: /aosp_15_r20/external/bazelbuild-rules_python/python/runfiles/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1# Copyright 2019 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("//python:defs.bzl", "py_library")
16load("//python:packaging.bzl", "py_wheel")
17load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED")
18
19filegroup(
20    name = "distribution",
21    srcs = glob(["**"]),
22    visibility = ["//python:__pkg__"],
23)
24
25py_library(
26    name = "runfiles",
27    srcs = [
28        "__init__.py",
29        "runfiles.py",
30    ],
31    data = ["py.typed"],
32    imports = [
33        # Add the repo root so `import python.runfiles.runfiles` works. This makes it agnostic
34        # to the --experimental_python_import_all_repositories setting.
35        "../..",
36    ],
37    visibility = ["//visibility:public"],
38)
39
40# This can be manually tested by running tests/runfiles/runfiles_wheel_integration_test.sh
41# We ought to have an automated integration test for it, too.
42# see https://github.com/bazelbuild/rules_python/issues/1002
43py_wheel(
44    name = "wheel",
45    # From https://pypi.org/classifiers/
46    classifiers = [
47        "Development Status :: 5 - Production/Stable",
48        "License :: OSI Approved :: Apache Software License",
49    ],
50    description_file = "README.md",
51    dist_folder = "dist",
52    distribution = "bazel_runfiles",
53    homepage = "https://github.com/bazelbuild/rules_python",
54    python_requires = ">=3.7",
55    strip_path_prefixes = ["python"],
56    twine = None if BZLMOD_ENABLED else "@rules_python_publish_deps_twine//:pkg",
57    # this can be replaced by building with --stamp --embed_label=1.2.3
58    version = "{BUILD_EMBED_LABEL}",
59    visibility = ["//visibility:public"],
60    deps = [":runfiles"],
61)
62