Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proto directory names preclude using protos in python code #1647

Closed
smparkes opened this issue Sep 3, 2020 · 4 comments
Closed

proto directory names preclude using protos in python code #1647

smparkes opened this issue Sep 3, 2020 · 4 comments

Comments

@smparkes
Copy link

smparkes commented Sep 3, 2020

The use of dashes in proto directory names precludes using those protos in python. protoc uses the path of the proto as the path of the generated python file name and so has to be a valid python package/module name.

There have been issues posted against protobuf asking to support a python_package option as there is a go_package option but resulting comments have mentioned that this would be problematic, particularly for bazel/blaze:
protocolbuffers/protobuf#7061
protocolbuffers/protobuf#2283
protocolbuffers/protobuf#973

So the question is, is there any tolerance for renaming the directories here so that the protos can be imported as external repos?

I can imagine this could be a breaking change for people using the project ...

@johanbrandhorst
Copy link
Collaborator

Hi Steven, thanks for your interest in the project!

This is moderately absurd, but lets see if we can figure something out. What protos exactly is it you're struggling to import? I assume you're talking about https://github.com/grpc-ecosystem/grpc-gateway/tree/master/protoc-gen-swagger/options? How are you importing them? It should really be possible for you to build them in your own folder structure, and so decide your own paths. Indeed, our README encourages users to copy the proto dependencies to their own protofile trees. If you take a look at my boilerplate repo, you can see that there is a third_party folder with the protofile dependencies. You should be able to do the same thing for your project, and you can use whatever names you like for your folders then.

Indeed, I don't think we could make this change, so hopefully we can find a workaround.

If you want more synchronous discussion, feel free to drop into our Slack support channel (#grpc-gateway on Gophers Slack).

@smparkes
Copy link
Author

smparkes commented Sep 4, 2020

What protos exactly is it you're struggling to import? I assume you're talking about https://github.com/grpc-ecosystem/grpc-gateway/tree/master/protoc-gen-swagger/options?

Yes, both protos in options.

How are you importing them?

We use bazel and include grpc-gateway as an external repo.

our README encourages users to copy the proto dependencies to their own protofile trees

Yeah, for what it's worth, we've succeeded in not doing this for any other external protos. Among others, we use external repos for com_google_protobuf and com_google_googleapis.

I understand that you might not have the appetite to make this change. We have a fork that renames the directory and adds a py_proto_library target. That will allow us to track changes from upstream ...

@smparkes
Copy link
Author

smparkes commented Sep 4, 2020

Happy to close this, leaving it for others that wish to take the same approach ...

@smparkes smparkes closed this as completed Sep 4, 2020
@johanbrandhorst
Copy link
Collaborator

Sorry that it had to be a fork, but thanks for raising the issue! That's a really unfortunate shortcoming of the Python proto rules.

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

No branches or pull requests

2 participants