Expose a py_proto_library target for build_event_stream.proto so that way the python programs outside the Bazel repo can consume the BEP
See original GitHub issueDescription of the feature request:
Make the src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto
file publicly visible. Alternatively, export the file with exports_files()
.
What underlying problem are you trying to solve with this feature?
I have a Python tool that needs to ingest the build event stream, so I’m trying to generate a Python protobuf library for the BES.
I’m using the @com_github_grpc_grpc//py_proto_library
rule as such:
py_proto_library(
name = "build_event_stream",
deps = ["@io_bazel//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_proto"],
)
However, since the proto file of interest is in an external workspace, the generated build_event_stream_proto_pb2.py
file has the following content which can’t be imported:
from ...io_bazel.src.main.java.com.google.devtools.build.lib.buildeventstream.proto.build_event_stream_pb2 import *
The workaround to this is to declare a filegroup
with the proto file of interest, manually build a local proto library, and then list that target as a dependency (I’ve verified that this approach works with public proto files such as @io_bazel//src/main/protobuf:extra_actions_base.proto
).
# This example should work, but doesn't since build_event_stream.proto is not publicly visible
py_proto_library(
name = "build_event_stream",
deps = [":build_event_stream_proto"],
)
proto_library(
name = "build_event_stream_proto",
srcs = [":build_event_stream_proto_file"],
)
filegroup(
name = "build_event_stream_proto_file",
srcs = ["@io_bazel//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream.proto"],
)
Unfortunately, this workaround does not work for this case because build_event_stream.proto
is not publicly visible.
Which operating system are you running Bazel on?
Ubuntu 20.04.4 LTS
What is the output of bazel info release
?
release 4.2.2
If bazel info release
returns development version
or (@non-git)
, tell us how you built Bazel.
No response
What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD
?
No response
Have you found anything relevant by searching the web?
Nothing exactly relevant, but there are a bunch of questions about which py_proto_library
rule to actually use (I’ve found 3 implementations…).
Any other information, logs, or outputs that you want to share?
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top GitHub Comments
On second thought, there’s already
//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto
with intentionally-public visibility. So that precedent makes me think we don’t need to think about setting a precedent ourselves here.Therefore I think the proposed change is very reasonable.
I too became interested in how
py_proto_library
is coming along, and found it’s now a PR: https://github.com/bazelbuild/rules_python/pull/832. Looks pretty close to going in!