Skip to content Skip to sidebar Skip to footer

Grpc: When Compiling Proto Files Into Python From Maven, Grpc.py Files Are Missing

When I generate grpc files from python (running python -m grpc_tools.protoc), I get 2 files for each one of the X proto files, X_pb2.py and X_pb2_grpc.py. However by using compile-

Solution 1:

It doesn't look like the xolstice Maven plugin supports this out of the box. gRPC code generation requires a plugin to the protoc compiler. This plugin is baked into the grpcio-tools package on PyPI. You'll have to compile the Python gRPC protoc plugin and supply it to protobuf-maven-plugin to make it work. The protocPlugin parameter looks like it should do what you want.

But at a higher level, is there a reason why you're using Maven to build Python artifacts?

Solution 2:

I have had great success with putting the compile command in a script and using the exec-maven-plugin to execute the script during compile.

I used a shell script to run a variation of the compile command from gRPC Quick Start. A little note is that no matter where you place the script, it will be run from project root unless you navigate to another folder inside the script.

Post a Comment for "Grpc: When Compiling Proto Files Into Python From Maven, Grpc.py Files Are Missing"