forked from stackb/rules_proto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_grpc_library.bzl
More file actions
30 lines (26 loc) · 1006 Bytes
/
python_grpc_library.bzl
File metadata and controls
30 lines (26 loc) · 1006 Bytes
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
load("//python:python_grpc_compile.bzl", "python_grpc_compile")
load("@protobuf_py_deps//:requirements.bzl", protobuf_requirements = "all_requirements")
load("@grpc_py_deps//:requirements.bzl", grpc_requirements = "all_requirements")
def python_grpc_library(**kwargs):
name = kwargs.get("name")
deps = kwargs.get("deps")
visibility = kwargs.get("visibility")
name_pb = name + "_pb"
python_grpc_compile(
name = name_pb,
deps = deps,
visibility = visibility,
verbose = kwargs.pop("verbose", 0),
transitivity = kwargs.pop("transitivity", {}),
transitive = kwargs.pop("transitive", True),
)
native.py_library(
name = name,
srcs = [name_pb],
deps = depset(protobuf_requirements + grpc_requirements).to_list(),
# This magically adds REPOSITORY_NAME/PACKAGE_NAME/{name_pb} to PYTHONPATH
imports = [name_pb],
visibility = visibility,
)
# Alias
py_grpc_library = python_grpc_library