Protomodel
Python Library to generate proto buffer code from python using type annotations
Installation
Create a virtual enviroment (Optional)
python -m venv venv
source venv/bin/activate # venv/Scripts/activate on Windows
Install package (require python ^3.10 version)
pip install protomodel
Example
Create a python file and add the following code:
from protomodel import message, service, rpc
@message
class HelloRequest:
name: str
@message
class HelloReply:
message: str
@service
class Greeter:
@rpc
def say_hello(hello_request: HelloRequest) -> HelloReply:
pass
Generate file
Run the following command to generate a proto buffer file:
python -m protomodel generate --python_file=hello.py --proto_name=hello.proto
And then you will get the following result:
syntax = "proto3";
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
Add a package name:
python -m protomodel generate --python_file=hello.py \
--proto_name=hello.proto --package_name=my_package_name
syntax = "proto3";
package my_package_name;
...
Adding another types
Python Code:
@message
class Item:
id: int
name: str
description: str
price: float
enabled: bool
@message
class ItemsList:
items: list[Item]
Result:
message Item {
int32 id = 1;
string name = 2;
string description = 3;
double price = 4;
bool enabled = 5;
}
message ItemsList {
repeated Item items = 1;
}
Metadata
Release files for protomodel 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| protomodel-0.0.13.tar.gz | 6.1 kB | Without provenance | Details for protomodel-0.0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| protomodel-0.0.13-py3-none-any.whl | Python 3 | none | any | Details for protomodel-0.0.13-py3-none-any.whl |
Total release size: 12.4 kB
Release files / protomodel-0.0.13.tar.gz
| Download URL | protomodel-0.0.13.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
789a82d6be23709faaf127f49f817663b2345e7891ecccd07cac9d741a8375f4
|
|
BLAKE2b-256 checksum How to use checksums |
de38de90a62fd4d237d167a76e419d13650c9fac0e12860756f43ed7cc90a46d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.3 Linux/5.15.90.1-microsoft-standard-WSL2
|
Release files / protomodel-0.0.13-py3-none-any.whl
| Download URL | protomodel-0.0.13-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ff7edc599e2281aaa175a3eaeb77c8552afae64cfcbcee83c269e028f78c1f8
|
|
BLAKE2b-256 checksum How to use checksums |
22c1e6925ec97288d9884473f37d9a7f7280b10217d046a7558be8f0f84b571f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.3 Linux/5.15.90.1-microsoft-standard-WSL2
|
Security for protomodel 0.0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.