python在代码中生成grpc

import pkg_resources
import sys

from grpc_tools import _protoc_compiler
def main(command_arguments):
    """Run the protocol buffer compiler with the given command-line arguments.

  Args:
    command_arguments: a list of strings representing command line arguments to
        `protoc`.
  """
    command_arguments = [argument.encode() for argument in command_arguments]
    return _protoc_compiler.run_main(command_arguments)


proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')

argv=['', '-I.', '--python_out=.', '--grpc_python_out=.', './helloworld.proto']
main(argv + ['-I{}'.format(proto_include)])
发布了150 篇原创文章 · 获赞 79 · 访问量 63万+

猜你喜欢

转载自blog.csdn.net/liu0808/article/details/103586107