Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Prototool doesn't generate all the needed files for python #555

Open
popadi opened this issue May 28, 2020 · 1 comment
Open

Prototool doesn't generate all the needed files for python #555

popadi opened this issue May 28, 2020 · 1 comment

Comments

@popadi
Copy link

popadi commented May 28, 2020

Hello!

I am trying to use prototool to generate the appropriate files for a python project. For a .proto service description containing gRPC services, the plain protoc generated code is synthesized in a _pb2.py file, and the gRPC-specifc code lands in a _grpc_pb2.py file. The latter python module imports the former. If you look at one of the python tutorials, you can see that after you run the protoc command you end up with two files: helloworld_pb2 and helloworld_pb2_grpc.

The command I use with a personal project to have both of them (so I can properly create the service and the client):

 python -m grpc_tools.protoc -I . --python_out ./build --grpc_python_out ./build quickstat2.proto

However, with --dry-run prototool does:

/home/[...]/protoc -I /home/[...]/protobuf/3.11.0/include -I . --python_out=/home/[...]/python /home/[..]/quickstat2.proto

So the --grpc_python_out flag is missing and my extra file is not properly generated. The documentation doesn't seem to say anything about this.

Is there a way to obtain the 2nd file by modifying something in the prototool configuration file?
Thank you!

@popadi popadi changed the title Prototool generate for python doesn't generate all needed files Prototool doesn't generate all the needed files for python May 28, 2020
@popadi
Copy link
Author

popadi commented May 28, 2020

Nevermind, this is a duplicate of #239. Sorry for not paying enough attention. You can also find info about it here: google/protobuf-gradle-plugin#250.

However, at this point you can't really build the plugin yourself using make grpc_python_plugin -j12 anymore as described in some comments (that are 2 years old). If you want to generate the other file, you need to use python -m grpc_tools.protoc and I'm not sure how I am supposed to do this from the prototool configuration file. It's not really something "you can add to the path" since (as I previously said) it's not installed separately.

Wherever you search something related to generating python classes for python, they don't use protoc but the python module (python -m grpc_tools.protoc). Using the path of the python module as the path for the plugin also doesn't work.

Anyone has any ideas or fixes that would easily work (hopefully) directly in the uber/prototools docker image? I can also build my own, but I'm not sure how can I achieve the desired results.
Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant