18 from grpc_tools
import protoc
25 inclusion_root = os.path.abspath(package_root)
26 for root, _, files
in os.walk(inclusion_root):
27 for filename
in files:
28 if filename.endswith(
'.proto'):
29 proto_files.append(os.path.abspath(os.path.join(root,
32 well_known_protos_include = pkg_resources.resource_filename(
33 'grpc_tools',
'_proto')
35 for proto_file
in proto_files:
38 '--proto_path={}'.
format(inclusion_root),
39 '--proto_path={}'.
format(well_known_protos_include),
40 '--python_out={}'.
format(inclusion_root),
41 '--grpc_python_out={}'.
format(inclusion_root),
43 if protoc.main(command) != 0:
45 raise Exception(
'error: {} failed'.
format(command))
47 sys.stderr.write(
'warning: {} failed'.
format(command))
51 """Command to generate project *_pb2.py modules from proto files."""
53 description =
'build grpc protobuf modules'
54 user_options = [(
'strict-mode',
's',
55 'exit with non-zero value if the proto compiling fails.')]