Imported Upstream version 1.27.0
[platform/upstream/grpc.git] / examples / python / cancellation / BUILD.bazel
1 # gRPC Bazel BUILD file.
2 #
3 # Copyright 2019 The gRPC authors.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 load("@grpc_python_dependencies//:requirements.bzl", "requirement")
18 load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
19
20 package(default_testonly = 1)
21
22 proto_library(
23     name = "hash_name_proto",
24     srcs = ["hash_name.proto"],
25 )
26
27 py_proto_library(
28     name = "hash_name_py_pb2",
29     deps = [":hash_name_proto"],
30 )
31
32 py_grpc_library(
33     name = "hash_name_py_pb2_grpc",
34     srcs = [":hash_name_proto"],
35     deps = [":hash_name_py_pb2"],
36 )
37
38 py_binary(
39     name = "client",
40     srcs = ["client.py"],
41     python_version = "PY3",
42     srcs_version = "PY2AND3",
43     deps = [
44         ":hash_name_py_pb2",
45         ":hash_name_py_pb2_grpc",
46         "//src/python/grpcio/grpc:grpcio",
47         "@six",
48     ],
49 )
50
51 py_library(
52     name = "search",
53     srcs = ["search.py"],
54     srcs_version = "PY2AND3",
55     deps = [
56         ":hash_name_py_pb2",
57     ],
58 )
59
60 py_binary(
61     name = "server",
62     srcs = ["server.py"],
63     python_version = "PY3",
64     srcs_version = "PY2AND3",
65     deps = [
66         "//src/python/grpcio/grpc:grpcio",
67         ":hash_name_py_pb2",
68         ":search",
69     ] + select({
70         "//conditions:default": ["@futures//:futures"],
71         "//:python3": [],
72     }),
73 )
74
75 py_test(
76     name = "test/_cancellation_example_test",
77     size = "small",
78     srcs = ["test/_cancellation_example_test.py"],
79     data = [
80         ":client",
81         ":server",
82     ],
83     python_version = "PY3",
84 )