python-betterproto icon indicating copy to clipboard operation
python-betterproto copied to clipboard

Split up the protoc plugin to make gRPC content configurable

Open nat-n opened this issue 5 years ago • 2 comments

Currently there is a single plugin with limited support for generating gRPC client code, and there is demand to cover servicer generation #19, with grpclib or grpcio, or none #44 #20 .

Since AFAIK there is not standard way to provide arguments to protoc plugins, I propose that the plugin be exposed as multiple distinct executables, one to generate just the protobuf dataclasses, one to generate the dataclasses and grpclib client/server and one to generate dataclasses and grpcio client/server.

Are there other approaches worth considering?

nat-n avatar May 23 '20 21:05 nat-n

Since AFAIK there is not standard way to provide arguments to protoc plugins, I propose that the plugin be exposed as multiple distinct executables

this is wrong. We can pass arguments to protoc just fine, e.g. protoc --python_betterproto_out=out --python_betterproto_opt=enable-grpc will put enable-grpc in the CodeGeneratorRequest's parameter field. It is usually a coma-delimited list of elements.

roblabla avatar Jan 21 '21 17:01 roblabla

Yeah this is an old issue, we actually use custom options https://github.com/danielgtaylor/python-betterproto/blob/master/src/betterproto/plugin/parser.py#L75

Gobot1234 avatar Jan 21 '21 17:01 Gobot1234