BUILD.bazel 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. load("@rules_proto//proto:defs.bzl", "proto_library")
  17. load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
  18. package(default_testonly = 1)
  19. proto_library(
  20. name = "hash_name_proto",
  21. srcs = ["hash_name.proto"],
  22. )
  23. py_proto_library(
  24. name = "hash_name_py_pb2",
  25. deps = [":hash_name_proto"],
  26. )
  27. py_grpc_library(
  28. name = "hash_name_py_pb2_grpc",
  29. srcs = [":hash_name_proto"],
  30. deps = [":hash_name_py_pb2"],
  31. )
  32. py_binary(
  33. name = "client",
  34. srcs = ["client.py"],
  35. python_version = "PY3",
  36. srcs_version = "PY2AND3",
  37. deps = [
  38. ":hash_name_py_pb2",
  39. ":hash_name_py_pb2_grpc",
  40. "//src/python/grpcio/grpc:grpcio",
  41. "@six",
  42. ],
  43. )
  44. py_library(
  45. name = "search",
  46. srcs = ["search.py"],
  47. srcs_version = "PY2AND3",
  48. deps = [
  49. ":hash_name_py_pb2",
  50. ],
  51. )
  52. py_binary(
  53. name = "server",
  54. srcs = ["server.py"],
  55. python_version = "PY3",
  56. srcs_version = "PY2AND3",
  57. deps = [
  58. "//src/python/grpcio/grpc:grpcio",
  59. ":hash_name_py_pb2",
  60. ":search",
  61. ] + select({
  62. "//conditions:default": ["@futures//:futures"],
  63. "//:python3": [],
  64. }),
  65. )
  66. py_test(
  67. name = "test/_cancellation_example_test",
  68. size = "small",
  69. srcs = ["test/_cancellation_example_test.py"],
  70. data = [
  71. ":client",
  72. ":server",
  73. ],
  74. python_version = "PY3",
  75. )