Skip to main content

setuptools plugin to generate python file from protobuf

Project description

setuptools-proto

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

Prerequisite

  • 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

setuptools.setup(
    setup_requires=['setuptools-proto'],
)

in setup.py in a imperative fashion or

[options]
setup_requires =
    setuptools-proto

in seutp.cfg in a declarative manner.

Configuration

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(
    ['proto/sample/**/*.proto'],
    cwd='proto/sample',
)
module2 = ProtoModule(
    ['demo/grpc/echo.proto', 'demo/grpc/hello.proto'],
    cwd='demo/grpc',
    out_dir='proto',
    include_dirs=['demo/schema'],
)


setup(
    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 setup.py --protoc /path/to/protoc build_proto

Execute

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.

Source Distribution

setuptools-proto-1.0.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

setuptools_proto-1.0.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file setuptools-proto-1.0.0.tar.gz.

File metadata

  • Download URL: setuptools-proto-1.0.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for setuptools-proto-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a7f6839c186fcc53e6d19806971acb6c6c244eecf61d8d24edd2a39af05dd6ae
MD5 76e5c146a48b035ec27b3a7a7ba41e35
BLAKE2b-256 1c693fcf0cfa9027be92b4cc4f0c27a9c2847d156844c6f84ab4a1f550c659da

See more details on using hashes here.

File details

Details for the file setuptools_proto-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: setuptools_proto-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for setuptools_proto-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75623e2c45f120262a814a9a841da363ae6574d544c925886cc05da611bae53d
MD5 5e1956f3d2378d0f931c01693d145002
BLAKE2b-256 1020f1e0082973939e590e5d98162098ed1a1d97c5815fc7fa6167ed89fa7c28

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page