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.7.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.7.0
File Size Uploaded Provenance Actions
protoc_gen_py-0.7.0.tar.gz 12.5 kB With provenance Details for protoc_gen_py-0.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 26.1 kB

Release files / protoc_gen_py-0.7.0.tar.gz

Download URL protoc_gen_py-0.7.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7c0a31581632ddb56172efb04ad6d2d5da11ecea0efdaadbda7bac7306f7e232
BLAKE2b-256 checksum
How to use checksums
d38f61053ae3b8ef64b78d7d3d5607fc15113bc07c836137b07cffe1091a2976
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 Oct 22, 2026.

Transparency log

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

Download URL protoc_gen_py-0.7.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37d651bd70d4384c73818aa06cc6496406eff3811b31f0efa69787ad7f1f3d2e
BLAKE2b-256 checksum
How to use checksums
8c6cb1b8f89726437bbc08196314d392b7f4208879273fc9176d54a207d4a6ea
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 Oct 22, 2026.

Transparency log

Security for protoc-gen-py 0.7.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for protoc_gen_py-0.7.0.tar.gz

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 Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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