Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed Python's grpcio module into a Bazel project

Tags:

python

grpc

bazel

I tried several different ways to embed the Python grpcio module into my Bazel project but unfortunately, none of them works correctly.

As far as I know, Bazel does not support injection of plugins into the Python environment (so you can directly run import grpcio). Note that Bazel does not support virtual-env and other tools (buildout...).

I found a way to include Pypi packages thanks to this proof of concept but unfortunately it does not work for grpc.io (environment variables are missing).

I am trying to debug the plugin, but I wonder if there is a better way to include grpcio module since the code is based on Bazel?

like image 573
FunkySayu Avatar asked Nov 09 '22 03:11

FunkySayu


1 Answers

As Nathaniel mentioned in the comments, bazel support for gRPC Python is still work in progress.

However, pubref https://github.com/pubref/rules_protobuf offers rules for bazel that support gRPC for all languages (including Python). I have used them for Java and they worked very well.

There is also a gRPC blog post about those rules: http://www.grpc.io/blog/bazel_rules_protobuf

like image 70
Jakob Buchgraber Avatar answered Nov 14 '22 22:11

Jakob Buchgraber