Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diamond protobuf dependency #380

Open
pjachowi opened this issue Nov 13, 2024 · 0 comments
Open

Diamond protobuf dependency #380

pjachowi opened this issue Nov 13, 2024 · 0 comments

Comments

@pjachowi
Copy link

Description

In my project I use rules_proto_grpc and independenty I use protobuf. When I run my project with bazel run I get the following error:

Traceback (most recent call last):
  File "/home/pjachowi/.cache/bazel/_bazel_pjachowi/837ec61bba9dc67ffa44001a7a1eb11f/execroot/_main/bazel-out/k8-fastbuild/bin/postumus/main/main.runfiles/_main/postumus/main/main_main.py", line 12, in <module>
    from proto import workflow_pb2_grpc
  File "/home/pjachowi/.cache/bazel/_bazel_pjachowi/837ec61bba9dc67ffa44001a7a1eb11f/execroot/_main/bazel-out/k8-fastbuild/bin/postumus/main/main.runfiles/_main/proto/workflow_py_proto_pb/proto/workflow_pb2_grpc.py", line 7, in <module>
    from proto import workflow_pb2 as proto_dot_workflow__pb2
  File "/home/pjachowi/.cache/bazel/_bazel_pjachowi/837ec61bba9dc67ffa44001a7a1eb11f/execroot/_main/bazel-out/k8-fastbuild/bin/postumus/main/main.runfiles/_main/proto/workflow_py_proto_pb/proto/workflow_pb2.py", line 9, in <module>
    from google.protobuf import runtime_version as _runtime_version
ImportError: cannot import name 'runtime_version' from 'google.protobuf' (bazel-out/k8-fastbuild/bin/postumus/main/main.runfiles/rules_python~~pip~pypi_311_protobuf/site-packages/google/protobuf/__init__.py)

The problem stems from the fact that rules_proto_grpc relies on its own protobuf containing runtime_version.py, but my project has implicite dependency on a different version of protobuf (4.25.5) which has no runtime_version.py.

In my sys.path the protobuf 4.25.5 comes first, then protobuf from rules_proto_grpc, hence from google.protobuf import runtime_version as _runtime_version finds first protobuf 4.25.5 and fails.

...
bazel-out/k8-fastbuild/bin/postumus/main/main.runfiles/rules_python~~pip~pypi_311_protobuf/site-packages
...
bazel-out/k8-fastbuild/bin/postumus/main/main.runfiles/rules_python~~pip~rules_proto_grpc_python_pip_deps_311_protobuf/site-packages

What is the recommended way to solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant