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
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description 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:
```bzl
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:
```py
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`).
```bzl
# 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_
Contributor guide
Assessment
This issue has not been assessed yet.