Skip to main content

protoc-gen-py

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

Installation

protoc-gen-py generates base types—messages and enumerations—from your Protocol Buffer schema. The generated code requires the runtime library protobuf-py. It's compatible with Protocol Buffer compilers like buf and protoc.

To install the runtime library and the plugin, run:

$ uv add protobuf-py protoc-gen-py buf-bin

Generating code

With buf

Add a new buf.gen.yaml configuration file:

version: v2
inputs:
  - directory: proto
plugins:
  # This will invoke protoc-gen-py and write output to src/gen
  - local: protoc-gen-py
    out: src/gen

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

$ uv run -- buf generate

Note that buf can generate from various inputs, not just local Protobuf files.

With protoc

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

Plugin options

init_files

By default, the plugin creates __init__.py files in every directory of the generated output. Set init_files=false to suppress this and produce namespace packages instead. Namespace packages allow multiple distribution packages to include modules under the same top-level package. For example, in buf.gen.yaml:

plugins:
  - local: protoc-gen-py
    out: src/gen
    opt: init_files=false

Metadata

Release files for protoc-gen-py 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for protoc-gen-py 0.6.0
File Size Uploaded
protoc_gen_py-0.6.0.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for protoc-gen-py 0.6.0
File Interpreter ABI Platform
protoc_gen_py-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.4 kB

Release files / protoc_gen_py-0.6.0.tar.gz

Download URL protoc_gen_py-0.6.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bbabd23eb5ba148cc7d968f04046363a524b085ec0320035032840853d61400a
BLAKE2b-256 checksum
How to use checksums
24f66500dddceb5cfc53ad54e7410efc933ba5098879aab853ab2a86ad42fae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / protoc_gen_py-0.6.0-py3-none-any.whl

Download URL protoc_gen_py-0.6.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97557d104ad0d98e1927be91a9fde875d63f7d64574f7ace9b5d02ffe9285222
BLAKE2b-256 checksum
How to use checksums
6f0553533263fce2309f22397bde30200239b452156114926e143cee625f4a6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page