Skip to main content

setuptools plugin to generate python file from protobuf

Project description


setuptools plugin to compile .proto files using python-betterproto.


  • Protobuf compiler protoc
  • Python 3.6+

Enable setuptools-proto

In either of the following scenarios, setuptools-proto will take effects.

  • Option 1, install setuptools-proto using pip or other tools:
$ pip install setuptools-proto
  • Option 2, require setuptools-proto in setup_requires keyword of setuptools.

So, add it either


in in a imperative fashion or

setup_requires =

in seutp.cfg in a declarative manner.


Protobuf modules

To let setuptools-proto know what to compile, define prot_modules as a ProtoModule list.

from setuptools import setup
from setuptools_proto import ProtoModule

module1 = ProtoModule(
module2 = ProtoModule(
    ['demo/grpc/echo.proto', 'demo/grpc/hello.proto'],

    proto_modules=[module1, module2],

protoc compiler

By default, setuptools-proto will use the system protoc compiler. If there's a custom install of protoc, which is not in the PATH, You can point environment variable PROTOC to it, or command line argument --protoc to it.

For example,

$ python --protoc /path/to/protoc build_proto


An extra command build_proto is added, to compile .proto to python code. This command will be automatically run before command build_py.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for setuptools-proto, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size setuptools_proto-1.0.0-py3-none-any.whl (7.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size setuptools-proto-1.0.0.tar.gz (14.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page