grpc / grpc/grpc.io

How to compile a client with Bazel? Need up to date docs

Open
#718 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
479
Forks
545
Avg merge
2d 7h
Merged PRs (30d)
5

Description

I'm trying to build a Python client using Bazel, and I'm most easily finding old information. Is there an up to date doc on how to do this?

A quick Google search turns up https://grpc.io/blog/bazel-rules-protobuf/. It's over four years old, and it points to a repo with the disclaimer "these rules are effectively no longer being maintained."

That disclaimer points to `https://github.com/stackb/rules_proto`. That repo also has a disclaimer "these rules...are in a pre-release status," all their builds are failing, and there's been no activity for a year.

So, I wound up poking around this project, and piecing together [WORKSPACE](https://github.com/Topher-the-Geek/dex/blob/topher/bazel-build/WORKSPACE) and [BUILD](https://github.com/Topher-the-Geek/dex/blob/topher/bazel-build/api/v2/BUILD) files. I have something that successfully generates a Python client.

```
$ bazel build //...
Starting local Bazel server and connecting to it...
INFO: Analyzed 5 targets (67 packages loaded, 3875 targets configured).
INFO: Found 5 targets...
INFO: Elapsed time: 8.036s, Critical Path: 0.24s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
$ ls bazel-bin/api/v2
api_pb2.py api_pb2_grpc.py api_proto-descriptor-set.proto.bin
```

Hooray! Then I attempted to move some of the material from the `WORKSPACE` above into a monorepo's `WORKSPACE` for a much larger project, and I tripped over interactions between these gRPC rules, [rules_python](https://github.com/bazelbuild/rules_python) and [rules_scala](https://github.com/bazelbuild/rules_scala).

Before I dig into this, I want to check with knowledgeable people. Am I doing this right?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.