https://github.com/zerlok/pyprotostuben
Generate python modules from protobuf files
https://github.com/zerlok/pyprotostuben
codegen mypy-stubs protobuf python python-protobuf
Last synced: 3 months ago
JSON representation
Generate python modules from protobuf files
- Host: GitHub
- URL: https://github.com/zerlok/pyprotostuben
- Owner: zerlok
- License: mit
- Created: 2024-05-11T15:58:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-01T13:14:50.000Z (4 months ago)
- Last Synced: 2025-07-05T20:53:51.863Z (3 months ago)
- Topics: codegen, mypy-stubs, protobuf, python, python-protobuf
- Language: Python
- Homepage:
- Size: 728 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyprotostuben
[](https://pypi.python.org/pypi/pyprotostuben)
[](https://pypi.python.org/pypi/pyprotostuben)
[](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration)
[](https://codecov.io/gh/zerlok/pyprotostuben)
[](https://pypistats.org/packages/pyprotostuben)
[](https://github.com/zerlok/pyprotostuben/stargazers)Generate Python modules from protobuf files.
## usage
[pypi package](https://pypi.python.org/pypi/pyprotostuben)
install with your favorite python package manager
```bash
pip install pyprotostuben
```Then use protoc plugins to generate python code. See [greeting examples](examples/greeting/README.md) for more info.
## protoc plugins
### protoc-gen-mypy-stub
Generates python stubs (`*_pb2.pyi` & `*_pb2_grpc.pyi` files which then used by MyPy type checker / IDE syntax highlits
& suggestions).**features:**
* choose message structure immutability / mutability
* choose async / sync grpc module stubs
* grpc servicer abstract methods have full signature (with appropriate type args in generics), thus it is easier to
implement methods in IDE**plugin options:**
* `message-mutable` -- add setters for fields, use mutable containers
* `message-all-init-args-optional` -- each field is optional in message constructor (even if field is not optional)
* `grpc-sync` -- use sync grpc stubs instead of grpc.aio module and async defs
* `grpc-skip-servicer` -- don't generate code for servicers
* `grpc-skip-stub` -- don't generate code for stubs
* `no-parallel` -- disable multiprocessing
* `debug` -- turn on plugin debugging### protoc-gen-brokrpc
Generates `*_brokrpc.py` modules for [BrokRPC](https://github.com/zerlok/BrokRPC) framework. This is similar to gRPC
codegen (`*_pb2_grpc.py` modules).**plugin options:**
* `no-parallel` -- disable multiprocessing
* `debug` -- turn on plugin debugging### protoc-gen-echo
Saves protoc plugin input to a file. Helps develop protoc plugins.
**plugin options:**
* `format={raw|binary|json}` (default = `raw`) -- specify output format
* `dest={path}` (default = `request.json`) -- specify file destination