Does py_proto_library work with proto_library target with strip_import_prefix configured
- Dominant language
- C++
- Stars
- 45.3k
- Forks
- 11.4k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 47
Description
### What version of gRPC and what language are you using?
v1.34.1
### What operating system (Linux, Windows,...) and version?
MacOS 10.15.7
### What runtime / compiler are you using (e.g. python version or version of gcc)
python 3.8.9, bazel 3.0.0
### What did you do?
I have a `proto_library` target defined like
```
proto_library(
name = "my_proto",
srcs = [
"my.proto",
],
strip_import_prefix = "/src/main/proto",
visibility = [
"//visibility:public",
],
)
```
When I try to use it in python with a `py_proto_library` target like
```
py_proto_library(
name = "my_pb2_py",
deps = [
"@my_workspace//path/to:my_proto",
],
)
```
Then when I run `bazel build`, I get error like
```
bazel-out/darwin-fastbuild/bin//path/to/_virtual_imports/my_proto/: No such file or directory
```
I confirmed this is caused by `strip_import_prefix= = "/src/main/proto"` in the `proto_library`, once removed, `bazel build` would work.
I also learned it's the `strip_import_prefix` that leads to the existence of `_virtual_imports` in the path, https://github.com/grpc/grpc/blob/fd3bd70939fb4239639fbd26143ec416366e4157/bazel/protobuf.bzl#L240-L244
I'd like to confirm if `py_proto_library` is expected to work with `proto_library` with `strip_import_prefix` configured?
reposted from https://stackoverflow.com/questions/67427575/does-py-proto-library-work-with-proto-library-target-with-strip-import-prefix-co
Contributor guide
Assessment
This issue has not been assessed yet.