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

Can't import grpc with rules_python #36

Open
juanzolotoochin opened this issue Aug 6, 2024 · 0 comments
Open

Can't import grpc with rules_python #36

juanzolotoochin opened this issue Aug 6, 2024 · 0 comments

Comments

@juanzolotoochin
Copy link

juanzolotoochin commented Aug 6, 2024

When using this toolchain when I do:

from examples.grpc.protos import helloworld_pb2_grpc

I get the following error:

Traceback (most recent call last):
  File "/home/juanique/.cache/bazel/_bazel_juanique/05c4bafe3bdc03c8ced122f9ff172535/sandbox/linux-sandbox/7866/execroot/monorepo/bazel-out/k8-fastbuild/bin/examples/repro/grpc_import.runfiles/monorepo/examples/repro/grpc_import.py", line 2, in <module>
    from examples.grpc.protos import helloworld_pb2_grpc
  File "/home/juanique/.cache/bazel/_bazel_juanique/05c4bafe3bdc03c8ced122f9ff172535/sandbox/linux-sandbox/7866/execroot/monorepo/bazel-out/k8-fastbuild/bin/examples/repro/grpc_import.runfiles/monorepo/examples/grpc/protos/helloworld_pb2_grpc.py", line 3, in <module>
    import grpc
  File "/home/juanique/.cache/bazel/_bazel_juanique/05c4bafe3bdc03c8ced122f9ff172535/sandbox/linux-sandbox/7866/execroot/monorepo/bazel-out/k8-fastbuild/bin/examples/repro/grpc_import.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/home/juanique/.cache/bazel/_bazel_juanique/05c4bafe3bdc03c8ced122f9ff172535/sandbox/linux-sandbox/7866/execroot/monorepo/bazel-out/k8-fastbuild/bin/examples/repro/grpc_import.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_compression.py", line 20, in <module>
    from grpc._cython import cygrpc
ImportError: /lib/x86_64-linux-gnu/libc.so: invalid ELF header

The same import works fine with the same workspace state but using the zig hermetic toolchain.

Here's a repro:

$ git clone https://github.com/juanique/monorepo.git
$ cd monorepo

# Clone a commit that is known to work without the musl toolchain
$ git checkout 4eeced95

# Verify that it passes with existing (zig hermetic c++) toolchain:
$ bazel test //examples/repro:grpc_import
//examples/repro:grpc_import                                             PASSED in 0.3s

# checkout branch that switches to musl toolchain
$ git checkout switch_to_musl_toolc_0b204

# run test again
$ bazel test //examples/repro:grpc_import

//examples/repro:grpc_import                                             FAILED in 0.2s

Test logs show the error above.

The diff for the branch can be seen in the following PR: juanique/monorepo#183

@juanzolotoochin juanzolotoochin changed the title Can't import grpc Can't import grpc with rules_python Aug 15, 2024
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