aboutsummaryrefslogtreecommitdiff
path: root/python/pip_install/tools/lib/BUILD.bazel
blob: 37a8b09be28acd03925d36e592574e37b231aa68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
load("//python:defs.bzl", "py_library", "py_test")
load(":annotations_test_helpers.bzl", "package_annotation", "package_annotations_file")

py_library(
    name = "lib",
    srcs = [
        "annotation.py",
        "arguments.py",
        "bazel.py",
    ],
    visibility = ["//python/pip_install:__subpackages__"],
)

package_annotations_file(
    name = "mock_annotations",
    annotations = {
        "pkg_a": package_annotation(),
        "pkg_b": package_annotation(
            data_exclude_glob = [
                "*.foo",
                "*.bar",
            ],
        ),
        "pkg_c": package_annotation(
            # The `join` and `strip` here accounts for potential differences
            # in new lines between unix and windows hosts.
            additive_build_content = "\n".join([line.strip() for line in """\
cc_library(
    name = "my_target",
    hdrs = glob(["**/*.h"]),
    srcs = glob(["**/*.cc"]),
)
""".splitlines()]),
            data = [":my_target"],
        ),
        "pkg_d": package_annotation(
            srcs_exclude_glob = ["pkg_d/tests/**"],
        ),
    },
    tags = ["manual"],
)

py_test(
    name = "annotations_test",
    size = "small",
    srcs = ["annotations_test.py"],
    data = [":mock_annotations"],
    env = {"MOCK_ANNOTATIONS": "$(rootpath :mock_annotations)"},
    deps = [
        ":lib",
        "//python/runfiles",
    ],
)

py_test(
    name = "arguments_test",
    size = "small",
    srcs = [
        "arguments_test.py",
    ],
    deps = [
        ":lib",
    ],
)

filegroup(
    name = "distribution",
    srcs = glob(
        ["*"],
        exclude = ["*_test.py"],
    ),
    visibility = ["//python/pip_install:__subpackages__"],
)

filegroup(
    name = "py_srcs",
    srcs = glob(
        include = ["**/*.py"],
        exclude = ["**/*_test.py"],
    ),
    visibility = ["//python/pip_install:__subpackages__"],
)