-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_protos.py
executable file
·45 lines (35 loc) · 1006 Bytes
/
gen_protos.py
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
#!/usr/bin/env python3
import os
import sys
from pathlib import Path
import pkg_resources
from grpc_tools import protoc
PROTO_WKT_PATH = pkg_resources.resource_filename('grpc_tools', '_proto')
GRPC_SRCS = [
'iruka_rpc.proto',
'iruka_admin.proto',
]
if __name__ == '__main__':
base_path = Path(__file__).parent.absolute()
client_path = base_path.parent / 'iruka_client'
src_base = client_path / 'iruka/protos'
protos = [str(src.relative_to(client_path)) for src in src_base.glob('*.proto')]
if not protos:
print('Unable to find any proto defs!', file=sys.stderr)
sys.exit(1)
os.chdir(client_path)
leading_args = (
'',
'-I.',
'-I{}'.format(PROTO_WKT_PATH))
protoc.main((
*leading_args,
'--python_out=.',
'--mypy_out=quiet:.',
*protos,
))
protoc.main((
*leading_args,
'--grpc_python_out=.',
*(str(Path('iruka/protos') / src) for src in GRPC_SRCS),
))