No project description provided
Project description
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-pymessages directly, with no dependency on the_pb2Protobuf 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.
Plugin options
io
Controls which flavor of code is generated:
- unset (default): generate both asynchronous (
grpc.aio) and synchronous (grpc) code; io=async: generate only asynchronous code;io=sync: generate only synchronous code.
For example, in buf.gen.yaml:
plugins:
- local: protoc-gen-grpc-py
out: src/gen
opt: io=async
Example
See the gRPC example for a complete client and server using the generated stubs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file protoc_gen_grpc_py-0.0.1.tar.gz.
File metadata
- Download URL: protoc_gen_grpc_py-0.0.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d4e0847d556d30e7a2eb9ee50e3100fe9310814ac1bec0c6ba69040fd2faee4
|
|
| MD5 |
008151ae6a69f7ec592d9acb362a6a40
|
|
| BLAKE2b-256 |
395865e27984f99f32b899055869ab08154779f24fc0afa192b48163fb50a352
|
Provenance
The following attestation bundles were made for protoc_gen_grpc_py-0.0.1.tar.gz:
Publisher:
release.yaml on bufbuild/protobuf-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protoc_gen_grpc_py-0.0.1.tar.gz -
Subject digest:
7d4e0847d556d30e7a2eb9ee50e3100fe9310814ac1bec0c6ba69040fd2faee4 - Sigstore transparency entry: 1927890466
- Sigstore integration time:
-
Permalink:
bufbuild/protobuf-py@96f80a47676c89cdc61aa416b517076e1b827111 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/bufbuild
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@96f80a47676c89cdc61aa416b517076e1b827111 -
Trigger Event:
push
-
Statement type:
File details
Details for the file protoc_gen_grpc_py-0.0.1-py3-none-any.whl.
File metadata
- Download URL: protoc_gen_grpc_py-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
167db43690de1b4182f2a8f8dda37792f25393622ddff1b9b213e53d7a862b9b
|
|
| MD5 |
0b30c0c7cc871d624fd4c7f336e8754a
|
|
| BLAKE2b-256 |
a5050fe5d2bea0a03e5b67411420d59672c3133d0c7242baff0457f423166cae
|
Provenance
The following attestation bundles were made for protoc_gen_grpc_py-0.0.1-py3-none-any.whl:
Publisher:
release.yaml on bufbuild/protobuf-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protoc_gen_grpc_py-0.0.1-py3-none-any.whl -
Subject digest:
167db43690de1b4182f2a8f8dda37792f25393622ddff1b9b213e53d7a862b9b - Sigstore transparency entry: 1927893782
- Sigstore integration time:
-
Permalink:
bufbuild/protobuf-py@96f80a47676c89cdc61aa416b517076e1b827111 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/bufbuild
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@96f80a47676c89cdc61aa416b517076e1b827111 -
Trigger Event:
push
-
Statement type: