-
-
Notifications
You must be signed in to change notification settings - Fork 650
Description
🐞 bug report
Affected Rule
The issue is caused by the rule: py_proto_library
Is this a regression?
No, this was never supported.
Description
If a proto_library A with strip_import_prefix depends on another proto_library B with strip_import_prefix, then the _virtual_imports locations for both A and B must be added to the PYTHONPATH (i.e., to the imports attribute for the generated py_library).
Currently, only the _virtual_imports for A are added to PYTHONPATH.
You can work around this by adding the py_proto_library for B directly to the deps of the py_library that depends on the py_proto_library for A, but it's clearly confusing.
🔬 Minimal Reproduction
This commit adds a unit test that reproduces the issue (as well as a proposed change to py_proto_library.bzl that fixes it): 214bb7c
🔥 Exception or Error
File "/usr/local/google/home/tpudlik/.cache/bazel/_bazel_tpudlik/1d5247c3691bed961cc8f7244214476e/sandbox/linux-sandbox/210/execroot/rules_python_py_proto_library_example/bazel-out/k8-fastbuild/bin/message_test.runfiles/rules_python_py_proto_library_example/example.com/another_pr
oto/_virtual_imports/message_proto/another_proto/message_pb2.py", line 14, in
from proto import pricetag_pb2 as proto_dot_pricetag__pb2
ModuleNotFoundError: No module named 'proto'
🌍 Your Environment
Operating System:
Linux
Output of bazel version:
6.2.0
Rules_python version:
2b05d9fba8cd7406c6c73549885210ba4771cc9e