-
Notifications
You must be signed in to change notification settings - Fork 541
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
Implement py_proto_library #832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, from dependencies management perspective.
FWIW transitive proto compilation with an aspect is probably not the right method to use any longer. Both rules_proto and rules_proto_grpc have dropped aspect based compilation in favour of more explicit direct compilation of the named protos only within a target. This is because transitive compilation is both artificially limiting in terms of passable options and more importantly leads to multiple definitions of the same proto message if depended on via differing trees (a serious problem in C++, a nuisance in Python). See here for further details: https://rules-proto-grpc.com/en/latest/transitivity.html |
a7233d3
to
94c2b4b
Compare
Compiling only directly is a good choice for gRPC generated libraries. For non-service proto libraries, it's better to use |
https://rules-proto-grpc.com/en/latest/transitivity.html says
Is there a place to further discuss this (this PR is probably not the best venue)? This situation sounds similar to some of the problems we have with SWIG (and C bindings in general) within Google, and pushing the codegen burden elsewhere has its own set of problems. @aaliddell |
You can email me or put it in a new discussion here; not sure I’ll be much help though with SWIG. Or put it on the bazel-discuss mailing list if you want a wider audience. Or slack. Too many options 😵💫
Ok, I thought I’d check your weren’t just blindly copying some of the other language rulesets’ behaviour without knowing the implications; seems like you’re on top of it 👍 |
per chat with Ivo: PR is not yet ready to merge; he's going to refactor things into a single bzlmod module file because deps for modules are fetched lazily (and thus no proto dep will be brought in unless necessary) |
I just ran into an interesting bug in the unofficial |
I just discovered this comment in com_google_protobuf//:protobuf.bzl.py_proto_library(). It suggests that Bazel 5.3 will include py_proto_library() internally. Is this the implementation? But only available when using bzlmod and/or Bazel 6? |
Still wrapping my head around bzlmod stuff. Is the idea that users would have to depend on the py_proto_module seperately from rules_python in their MODULE.bazel file in order to use the py_proto_library rule; or would any dependency on rules_python include the ability to use py_proto_library? |
f9b5fff
to
8981c4b
Compare
Yes, this is the implementation. It will work with Bazel 5.3 and Bazel 6. And also without bzlmod.
I fixed the PR, so that the users only need to depend on rules_python. And proto repositories are fetched only if you use py_proto_library, |
8981c4b
to
1e24ebb
Compare
1e24ebb
to
4ab5a5d
Compare
The PR is now ready. |
This forgot to update the docs/ folder so that the new stardoc comments are published for users to find. |
* Add py_proto_library * Bump versions of rules_proto and protobuf * Update documentation * Bump rules_pkg version
py_proto_library
was tested manually on Bazel repository using Bazel 6.0.0 with and without using bzlmod.Extend README.md to mention also
py_proto_library
.With bzlmod
py_proto_library
just works. Users without bzlmod, need to importrules_proto
andprotobuf
repositories into theirWORKSPACE
file.py_proto_library
is compatible with Bazel>=5.4.0
and>=6.0.0
.