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
usingpip
or other tools:
$ pip install setuptools-proto
- Option 2, require
setuptools-proto
insetup_requires
keyword ofsetuptools
.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for setuptools_proto-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75623e2c45f120262a814a9a841da363ae6574d544c925886cc05da611bae53d |
|
MD5 | 5e1956f3d2378d0f931c01693d145002 |
|
BLAKE2b-256 | 1020f1e0082973939e590e5d98162098ed1a1d97c5815fc7fa6167ed89fa7c28 |