Closed siva-tonita closed 1 year ago
In particular, without the python_grpc_library
dependency //A/B/C:baz_py_grpc
. bazel run A/B:bar
legitimately builds A:foo
(as can be verified by the presence of A/__pycache__/
with foo.cpython-310.pyc
inside it (this is all under bazel-bin/A/B/bar.runfiles/__main__/
). Similarly, if we just run bazel build A:foolib
, we see the __pycache__
dir.
However, with that dependency //A/B/C:baz_py_grpc
, I am not seeing the __pycache__
directory, confirming that the target A:foolib
is not built.
Have you tried setting legacy_create_init = False,
on your py_binary
? The default mode is somewhat broken how it handles overlapping import trees
Thank you for the suggestion; fixes our problem (for now; hopefully it will be easy to identify the missing __init__.py
requirements in srcs
and deps
for any future breakages).
Closing the Issue with much appreciation for your help!
Issue Description
Thank you for a lovely repo!
We tried using rules_proto_grpc to set up a Python gRPC server, and are running into a strange error where including a python_grpc_library target as a dependency causes unexpected (and incorrect) import errors elsewhere.
Here's a minimal "toy" version where we're seeing errors (on a n2-standard-8 VM on Google Cloud, with Python 3.10.11).
Three directories under the repo root: A, A/B, and A/B/C.
Trying to
bazel run A/B:bar
works if the dependency "/A/B/C:baz_py_grpc" stays commented out; if it is UNCOMMENTED, thebazel run
generates the error "ModuleNotFoundError: No module named 'A.foo'" -- and we're absolutely stumped.It is not clear at all why that dependency messes with the normal Python import structure. Would be great if it can be debugged / fixed. Thanks in advance! rules_proto_grpc_issue.tar.gz
Log Output
rules_proto_grpc Version
4.4.0
Bazel Version
6.2.1
OS
Debian
Link to Demo Repo
No response
WORKSPACE Content
BUILD Content
Proto Content
Any Other Content
No response