I am new to the Python gRPC implementation.
In Python, the gRPC project proto files are shipped in smaller packages. For example, I want to use status.proto
, which is the grpc-status
package.
The protoc
compiler is provided as a Python module by the grpc-tools
package.
# my.proto
syntax = "proto3";
import "google/rpc/status.proto";
Installing everything in a virtualenv:
python -m venv v
source v/bin/activate
pip install grpc-status grpc-tools
The compiler module doesn’t automatically find and use the proto files installed by the grpc-status
package.
python -m grpc_tools.protoc -I . my.proto
Results in:
google/rpc/status.proto: File not found.
This surprises me, because the proto files are distributed in separate modules, and the protoc
compiler is itself a Python module, and so the entire arrangement for “provided” proto files seems easy and designed to be configured within Python by grpc_tools
itself. It seems I must be doing something wrong.
Do I really need to do this?
SITE_PROTO_FILES=$( python -c 'import site; print(site.getsitepackages()[0])' )
python -m grpc_tools.protoc -I $SITE_PROTO_FILES -I . my.proto
I have searched the gRPC documentation, Google Group and GitHub Issue tracker, but have not found anything useful about this.