protoc
contains just logic for protocol buffers. That is, it will generate serialization/deserialization code for many languages. It does not, however, generate code for stubs and servers by default. This is left up to separate RPC systems through a system called protoc plugins.
Protoc plugins offer a simple interface by which an executable takes a description of a Protocol Buffer on stdin and outputs the corresponding generated code on stdout. Internal to Google, this system is used to generate code for Stubby. Externally, it is used to generate code for gRPC (or any other RPC system that wants to use protocol buffers).
Plugins get to register a command line flag for themselves to indicate where protoc should output the generated code. So, in your example above, --python_out
indicates where the generated serialization/deserialization code should go, while --grpc_python_out
is the flag registered by the gRPC Python code generator, indicating where Python stub and server code should be placed on the filesystem.
grpc_tools
is a C extension bundling both protoc
and the gRPC Python protoc plugin together so that the user doesn't have to deal with downloading protoc
, downloading the gRPC Python code generator, and getting the necessary configuration set up to make them work together properly. However, in theory, you should be able to put all these pieces together to make them work just like grpc_tools
(though I haven't tried).