Protocol Buffers at runtime
Project description
Protosaurus
Parse and create Protobuf messages at runtime in Python — no protoc required. Also includes a CLI to deserialize Protobuf from Kafka using kcat and a schema registry.
Installation
Requires Python >= 3.12.
uv add protosaurus
Or using pip:
pip install protosaurus
Usage
Parse and serialize Protobuf in Python
Protosaurus can parse .proto definitions at runtime without using protoc. This allows Protobuf byte arrays to be converted to JSON and vice versa. The Context object is thread-safe and can be shared across threads.
import json
from protosaurus import Context
from base64 import b64decode
# create a context which stores the proto schemas
ctx = Context()
# add protos by specifying name and content
ctx.add_proto('diet.proto',
"""
syntax = "proto3";
enum Diet {
carnivorous = 0;
herbivorous = 1;
}
""")
# the proto can be imported via the specified name
ctx.add_proto('animal.proto',
"""
syntax = "proto3";
import "diet.proto";
message Animal {
string name = 1;
Diet diet = 2;
double length = 3;
}
""")
# convert a message from base64 string...
data = ctx.to_json('Animal', b64decode('CglJZ3Vhbm9kb24QARkAAAAAAAAkQA=='))
# ...or hex string
data = ctx.to_json('Animal', bytes.fromhex('0a09496775616e6f646f6e1001190000000000002440'))
print(data)
# >>> '{"name":"Iguanodon","diet":"herbivorous","length":10}'
# convert json to protobuf
data = ctx.from_json('Animal', json.dumps({"name":"Iguanodon","diet":"herbivorous","length":10}))
print(data)
# >>> b'\n\tIguanodon\x10\x01\x19\x00\x00\x00\x00\x00\x00$@'
Deserialize Protobuf from Kafka using a schema registry
Protosaurus also ships a CLI that can deserialize Protobuf messages from Kafka automatically when a schema registry is available:
kcat -C -e -F <kafka.config> -t <topic> -f "%o\\n%k\\n%R%s" | protosaurus - --schema-registry <url>
To disable SSL certificate verification (e.g. for self-signed certificates), pass --no-verify:
kcat -C -e -F <kafka.config> -t <topic> -f "%o\\n%k\\n%R%s" | protosaurus - --schema-registry <url> --no-verify
Using uvx (no installation required):
kcat -C -e -F <kafka.config> -t <topic> -f "%o\\n%k\\n%R%s" | uvx protosaurus - --schema-registry <url>
License
ISC License — see LICENSE for details.
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file protosaurus-0.4.0.tar.gz.
File metadata
- Download URL: protosaurus-0.4.0.tar.gz
- Upload date:
- Size: 183.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b5095208b1cf796cad197691b3496f86691102afc242fc494c1adcba6ffce04
|
|
| MD5 |
bbe055160ad7d7c10cd4bbaeecfbfa01
|
|
| BLAKE2b-256 |
1c68e695604b974adc04d88b504c3b8d0df48cf4f14c5fb71e2a7406ab31f1ca
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0.tar.gz:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0.tar.gz -
Subject digest:
7b5095208b1cf796cad197691b3496f86691102afc242fc494c1adcba6ffce04 - Sigstore transparency entry: 1585035849
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file protosaurus-0.4.0-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: protosaurus-0.4.0-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 743.8 kB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0069ce32c624ae442a7896c28fcded1d9b4292f744680d2993438898eabdf9a1
|
|
| MD5 |
da81c344010cd9de6c57e685d091b47e
|
|
| BLAKE2b-256 |
04ad646293b4768bfb05e52661db91af06e5c1defc92ff45d378b75ecc0ddf8b
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0-cp312-abi3-win_amd64.whl:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0-cp312-abi3-win_amd64.whl -
Subject digest:
0069ce32c624ae442a7896c28fcded1d9b4292f744680d2993438898eabdf9a1 - Sigstore transparency entry: 1585036273
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file protosaurus-0.4.0-cp312-abi3-win32.whl.
File metadata
- Download URL: protosaurus-0.4.0-cp312-abi3-win32.whl
- Upload date:
- Size: 677.9 kB
- Tags: CPython 3.12+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c01a12a78c8383851f3937654dde820860171880fcea724adefd138b5249a31b
|
|
| MD5 |
afb07e03e33d35e2d76306250b0eec5c
|
|
| BLAKE2b-256 |
7bcd63d8c3dc984de49c9c7654c109fc0177716823c3a58a679bc74675325534
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0-cp312-abi3-win32.whl:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0-cp312-abi3-win32.whl -
Subject digest:
c01a12a78c8383851f3937654dde820860171880fcea724adefd138b5249a31b - Sigstore transparency entry: 1585036668
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file protosaurus-0.4.0-cp312-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: protosaurus-0.4.0-cp312-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f486b7bbb96ebcdf960036c4aa412f89c58bf4308729e424331ec8c1a63a7a12
|
|
| MD5 |
bfcc577db621e5a788c316defced4362
|
|
| BLAKE2b-256 |
42a169bdbade01c06c9df0aea91ec78fd75a0b3c05bb001ce1ea6b50159f01d3
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0-cp312-abi3-musllinux_1_2_x86_64.whl:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0-cp312-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
f486b7bbb96ebcdf960036c4aa412f89c58bf4308729e424331ec8c1a63a7a12 - Sigstore transparency entry: 1585036550
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file protosaurus-0.4.0-cp312-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: protosaurus-0.4.0-cp312-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc9435f7266fb0108bf90bda67c38fde8db4ec8e97624ade6cd1a7c3b8de57a
|
|
| MD5 |
c2078f184883a7f262dd18669e99051b
|
|
| BLAKE2b-256 |
f620fc3a048f7f4a04cb46000024dfe7ce79bcff3c7fbf1c12ec1ff12a61eae9
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0-cp312-abi3-musllinux_1_2_aarch64.whl:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0-cp312-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
5cc9435f7266fb0108bf90bda67c38fde8db4ec8e97624ade6cd1a7c3b8de57a - Sigstore transparency entry: 1585036138
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file protosaurus-0.4.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: protosaurus-0.4.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12+, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57b0a1f832399c21e79b76b0344fc84caef2304788d6a9eb56712c36656f95f8
|
|
| MD5 |
db42fe63419d40d827272f97a17d4bcf
|
|
| BLAKE2b-256 |
06bc19a8fc54057019c58b4518b37ac6b069f24f58675f42c5ca2e458d731d02
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
57b0a1f832399c21e79b76b0344fc84caef2304788d6a9eb56712c36656f95f8 - Sigstore transparency entry: 1585036766
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file protosaurus-0.4.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: protosaurus-0.4.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12+, manylinux: glibc 2.26+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95f38c4dd91e9c2280f37be83674675b7218746a82d1712cc499a48d281c89b7
|
|
| MD5 |
f575188a76ba07d9b49d2e39af2a73c4
|
|
| BLAKE2b-256 |
4026f6ad7f522c7327e9391859bccb11b091628c0d1be8e4b83286025ee3d76a
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
95f38c4dd91e9c2280f37be83674675b7218746a82d1712cc499a48d281c89b7 - Sigstore transparency entry: 1585036009
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file protosaurus-0.4.0-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: protosaurus-0.4.0-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 872.2 kB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
299e421370463f7f7d2d3825b65370ee6da93d561f4b915b3cdb7140c1e70faa
|
|
| MD5 |
496d7403c6274324a3f066a3b6ee62dc
|
|
| BLAKE2b-256 |
c54ece06172649e6c7490a2ef100b11c0355212a641604c0ba06aebc2add16ca
|
Provenance
The following attestation bundles were made for protosaurus-0.4.0-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on oberbichler/protosaurus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
protosaurus-0.4.0-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
299e421370463f7f7d2d3825b65370ee6da93d561f4b915b3cdb7140c1e70faa - Sigstore transparency entry: 1585036441
- Sigstore integration time:
-
Permalink:
oberbichler/protosaurus@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Branch / Tag:
refs/tags/0.4.0 - Owner: https://github.com/oberbichler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@1d7bf910043cb36d14fa66e747b7ca13eb0f2dc8 -
Trigger Event:
release
-
Statement type: