skillfed

hatch-protobuf

A Hatch build plugin to generate Python files from Protocol Buffers .proto files

hatch-protobuf v0.5.0 190.5K downloads/30d#9,908 on PyPI14
Copyleft license MPL-2.0 Active released

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-protobuf

uv

uv add hatch-protobuf

poetry

poetry add hatch-protobuf

Installing 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

Development Status :: 2 - Pre-AlphaFramework :: HatchIntended Audience :: DevelopersProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Code Generators

Tags

protobuf code generationhatch build plugin protobufgrpc python file generationproto to python compilerhatch protobuf integrationprotocol buffers build hookgrpcio code generator
protobufgrpcbuild-automation

More Code Generators packages

proto-plus

Proto Plus wraps protocol buffers to provide…

permissive · top 1,000 on PyPI

Cython

Cython is a source code translator that…

permissive · top 1,000 on PyPI

asttokens

Annotates Python abstract syntax trees with the…

permissive · top 1,000 on PyPI

beartype

Beartype is a runtime type checker that…

permissive · top 1,000 on PyPI

llvmlite

llvmlite provides a lightweight Python binding…

permissive · top 1,000 on PyPI

astor

astor converts Python abstract syntax trees…

permissive · top 5,000 on PyPI

grpcio-tools

Generates Python gRPC service stubs and message…

permissive · top 1,000 on PyPI

opensearch-protobufs

Provides pre-generated Python Protocol Buffer…

permissive · top 5,000 on PyPI

protoletariat

Protoletariat rewrites Python imports generated…

permissive · top 5,000 on PyPI

setuptools-protobuf

A setuptools plugin that automates compilation…

permissive · top 15,000 on PyPI

nanopb

Nanopb is a code generator and runtime library…

permissive · top 15,000 on PyPI

grpc-gateway-protoc-gen-openapiv2

Generates Python support code for gRPC Gateway…

permissive · top 15,000 on PyPI

protoc-gen-openapiv2

Generates Python support code for gRPC Gateway…

permissive · top 5,000 on PyPI

aristaproto

Generates Python gRPC stubs and message classes…

permissive · top 15,000 on PyPI

pylint-protobuf

A Pylint plugin that makes Pylint understand…

permissive · top 15,000 on PyPI

protobuf_to_pydantic

Converts Protobuf message definitions into…

permissive · top 15,000 on PyPI