Example #1
0
 def run(self):
     # due to limitations of the proto generator, we require that only *one*
     # directory is provided as an 'include' directory. We assume it's the '' key
     # to `self.distribution.package_dir` (and get a key error if it's not
     # there).
     from grpc_tools import command
     command.build_package_protos(self.distribution.package_dir[''])
Example #2
0
 def run(self):
     # due to limitations of the proto generator, we require that only *one*
     # directory is provided as an 'include' directory. We assume it's the '' key
     # to `self.distribution.package_dir` (and get a key error if it's not
     # there).
     from grpc_tools import command
     command.build_package_protos(self.distribution.package_dir[''])
    def run(self):
        try:
            # python 3.4+ should use builtin unittest.mock not mock package
            from unittest.mock import patch
        except ImportError:
            from mock import patch
        import grpc_tools
        import os
        import sys
        from grpc_tools.protoc import main as grpc_tools_protoc_main

        if GRPC_INSTALLED:
            def _mock_main(command_arguments):
                # insert arguments for mypy_protobuf
                # https://github.com/dropbox/mypy-protobuf
                mypy_out = os.path.abspath(self.distribution.package_dir[""])
                command_arguments.insert(len(command_arguments) - 1, "--mypy_out={}{}".format("quiet:", mypy_out))
                # "On windows, provide the bat file"
                if os.name == 'nt':
                    path_to_protoc_gen_mypy = Path(sys.executable).parent / "protoc_gen_mypy.bat"
                    if not path_to_protoc_gen_mypy.exists():
                        raise FileNotFoundError("Can't found {} !".format(path_to_protoc_gen_mypy.parent))
                    command_arguments.insert(1, "--plugin=protoc-gen-mypy={}".format(str(path_to_protoc_gen_mypy)))

                return grpc_tools_protoc_main(command_arguments)

            with patch.object(grpc_tools.protoc, "main", _mock_main):
                command.build_package_protos(self.distribution.package_dir[""])
        else:
            raise ModuleNotFoundError("grpcio-tools is needed in order to generate the proto classes")
Example #4
0
 def run(self):
     # due to limitations of the proto generator, we require that only *one*
     # directory is provided as an 'include' directory. We assume it's the '' key
     # to `self.distribution.package_dir` (and get a key error if it's not
     # there).
     build_package_protos(
         self.distribution.package_dir["mpi_network_proto"],
         self.strict_mode)
Example #5
0
 def run(self):
     if GRPC_INSTALLED:
         command.build_package_protos(self.distribution.package_dir[''])
     else:
         raise ModuleNotFoundError("grpcio-tools is needed in order to "
                                   "generate the proto classes")
 def run(self):
     from grpc_tools.command import build_package_protos
     build_package_protos('.')