hatch-protobuf
A Hatch build plugin to generate Python files from Protocol Buffers .proto files
What it is and what it does
hatch-protobuf is a build-time plugin for the Hatch package manager that automates the generation of Python code from Protocol Buffer definitions. It wraps grpcio-tools' protoc compiler and integrates it into Hatch's build hook system, so `.proto` files are compiled to Python during package builds without manual steps.
The plugin generates Python message classes and gRPC service stubs by default, with optional `.pyi` type stub files for static analysis. It supports custom generators (e.g., for TypeScript or other languages), can import `.proto` definitions from installed packages via site-packages, and allows configuration of input/output paths and protoc options through `pyproject.toml`. It's designed for projects that use Protocol Buffers as part of their build process and want code generation to happen automatically during packaging.
Use it for:
- Generate gRPC service stubs and message classes during package build for microservices that use Protocol Buffers.
- Consume `.proto` definitions from published packages (e.g., googleapis-common-protos) without rebuilding them.
- Integrate custom protoc plugins (TypeScript, Go, etc.) into a Python project's build pipeline.
- Maintain type stubs (.pyi files) alongside generated Protocol Buffer code for IDE and mypy support.
- Automatically compile `.proto` files in src-layout or flat-layout projects with sensible defaults.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Hatch build plugin that generates Python files from Protocol Buffers `.proto` files using grpcio-tools, with support for gRPC, type stubs, and custom generators.
Yes, if you use Hatch and Protocol Buffers. Low friction to install, no known vulnerabilities, actively maintained, and solves a real build-automation problem. The pre-alpha status (Development Status :: 2) suggests the API may change, so pin the version in your build dependencies. Not worth installing if you don't use Hatch or don't generate code from `.proto` files.
Install
hatch-protobuf on PyPI
pip
pip install hatch-protobufuv
uv add hatch-protobufpoetry
poetry add hatch-protobufInstalling hatch-protobuf
Before you install
Low install friction; pure Python wheel with only two runtime dependencies (grpcio-tools and hatchling). Repository is active with recent commits and no known vulnerabilities.
License in practice
Licensed under MPL-2.0 (copyleft). You must disclose source code modifications and distribute under the same license if you modify the plugin itself, though generated code is not affected.
Quickstart
# Add to pyproject.toml:
[tool.hatch.build.hooks.protobuf]
dependencies = ["hatch-protobuf"]
# Then run:
pip install hatch-protobuf
hatch build
Requires Hatch as your build system; grpcio-tools must be available in your environment to run protoc.
Verify before relying
- Whether custom protoc plugins (e.g., TypeScript generators) work reliably with non-Python targets.
- Performance characteristics when processing large numbers of .proto files or deeply nested proto_paths.
- Compatibility with editable installs of packages that provide .proto files for import.
Package facts
| License | MPL-2.0 (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — grpcio-tools, hatchling |
| Maintenance | actively maintained — 394 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 190,511/month — #9,908 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: hatch_protobuf-0.5.0-py3-none-any.whl
Keywords: grpc, hatch, protobuf
Tags
More Code Generators packages
Proto Plus wraps protocol buffers to provide…
permissive · top 1,000 on PyPI
CythonCython is a source code translator that…
permissive · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
beartypeBeartype is a runtime type checker that…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
opensearch-protobufsProvides pre-generated Python Protocol Buffer…
permissive · top 5,000 on PyPI
protoletariatProtoletariat rewrites Python imports generated…
permissive · top 5,000 on PyPI
setuptools-protobufA setuptools plugin that automates compilation…
permissive · top 15,000 on PyPI
nanopbNanopb is a code generator and runtime library…
permissive · top 15,000 on PyPI
grpc-gateway-protoc-gen-openapiv2Generates Python support code for gRPC Gateway…
permissive · top 15,000 on PyPI
protoc-gen-openapiv2Generates Python support code for gRPC Gateway…
permissive · top 5,000 on PyPI
aristaprotoGenerates Python gRPC stubs and message classes…
permissive · top 15,000 on PyPI
pylint-protobufA Pylint plugin that makes Pylint understand…
permissive · top 15,000 on PyPI
protobuf_to_pydanticConverts Protobuf message definitions into…
permissive · top 15,000 on PyPI