Skip to main content

protoc-gen-grpc-py

The gRPC code generator plugin for Protocol Buffers for Python. Learn more about the project at github.com/bufbuild/protobuf-py.

Overview

protoc-gen-grpc-py generates fully typed, idiomatic gRPC clients and servicers that use protobuf-py messages for serialization. Unlike the stock gRPC Python plugin, the generated stubs:

  • are fully typed, so editors and type checkers understand every RPC method
  • serialize protobuf-py messages directly, with no dependency on the _pb2 Protobuf runtime
  • ship both asyncio (grpc.aio) and synchronous variants.

For each service it emits a servicer base class (with an add_to_server method) and a client, in both async and sync flavors (the sync names are suffixed with Sync). Message types are generated separately by protoc-gen-py.

Installation

The generated code requires the runtime libraries protobuf-py and grpcio. The plugin is compatible with Protocol Buffer compilers like buf and protoc.

$ uv add protobuf-py grpcio
$ uv add --dev protoc-gen-py protoc-gen-grpc-py buf-bin

Generating code

With buf

Add protoc-gen-grpc-py alongside protoc-gen-py in your buf.gen.yaml:

version: v2
inputs:
  - directory: proto
plugins:
  # Generates message types (*_pb.py).
  - local: protoc-gen-py
    out: src/gen
  # Generates gRPC service stubs (*_pb_grpc.py).
  - local: protoc-gen-grpc-py
    out: src/gen

To generate code for all Protobuf files within your project, run:

$ uv run -- buf generate

With protoc

$ uv run protoc --proto_path proto \
    --py_out src/gen \
    --grpc-py_out src/gen \
    proto/a.proto proto/b.proto proto/c.proto

A *_pb_grpc.py file is generated only for proto files that declare a service. The plugin does not emit __init__.py files; let protoc-gen-py manage those.

Example

See the gRPC example for a complete client and server using the generated stubs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protoc_gen_grpc_py-0.1.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

protoc_gen_grpc_py-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file protoc_gen_grpc_py-0.1.1.tar.gz.

File metadata

  • Download URL: protoc_gen_grpc_py-0.1.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for protoc_gen_grpc_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f2b22a121ef7b3a87219b8bcd547f4cf4103511e1f6f7de3d27f06ed9b5c20f8
MD5 c8bd9049f76574a34d47b16decf6764a
BLAKE2b-256 5bf05794862a884d99aca2866d5636fe6d15c476d13cbc6e58d1267134cdd76b

See more details on using hashes here.

Provenance

The following attestation bundles were made for protoc_gen_grpc_py-0.1.1.tar.gz:

Publisher: release.yaml on bufbuild/protobuf-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file protoc_gen_grpc_py-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for protoc_gen_grpc_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 33bb226ab29e672489fc663a4a174ebc8e5ae6c26026cfd3350287a76569bfde
MD5 c2623ec688852d22341db09e27e485f5
BLAKE2b-256 c2ceaeef949c2f29db4ff1f5a6f08e209c30fee1f1f65627e686476a0d14076e

See more details on using hashes here.

Provenance

The following attestation bundles were made for protoc_gen_grpc_py-0.1.1-py3-none-any.whl:

Publisher: release.yaml on bufbuild/protobuf-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page