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

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_py-0.5.0.tar.gz (11.0 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_py-0.5.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file protoc_gen_py-0.5.0.tar.gz.

File metadata

  • Download URL: protoc_gen_py-0.5.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for protoc_gen_py-0.5.0.tar.gz
Algorithm Hash digest
SHA256 c2fd5873f9e0542d7fcb043276e7a7314b4fafb2c1329aaee42c188ab907466a
MD5 9a646f0539b1218f4b97764ff1563f3c
BLAKE2b-256 6512ae2f4b8bd53c890100c185fa897f111120ce04425d8c75c066f650af76aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for protoc_gen_py-0.5.0.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_py-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: protoc_gen_py-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for protoc_gen_py-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5162b067ee1a09d4a6bea3171f740a93a7d1493b9afbc262f994c0e835347ea0
MD5 4d7ddb4e333af21909181cde01844987
BLAKE2b-256 1b792bf2236ce4b9e1e8783f35fa61c63009a5c5881fca56cb99f1acea074f1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for protoc_gen_py-0.5.0-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.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.2

2 files

0.0.1

2 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