Twirp runtime library for Python
Project description
Twirpy
Twirp is a framework for service-to-service communication emphasizing simplicity and minimalism. It generates routing and serialization from API definition files and lets you focus on your application's logic instead of thinking about folderol like HTTP methods and paths and JSON.
Twirpy is a Python implementation of the Twirp framework. It currently supports Twirp Wire Protocol v7.
This repository contains:
- a protoc (aka the Protocol Compiler) plugin that generates sever and client code;
- a Python package with common implementation details.
Installation
Runtime Library
The runtime library package contains common types like TwirpServer and TwirpClient that are used by the generated code.
Add the Twirp package to your Python project with:
pip install twirpy
Code Generator
You need to install protoc, the Protocol Buffers compiler, and the protoc-gen-twirpy protoc plugin to generate code.
First, install the Protocol Buffers compiler.
For installation instructions, see Protocol Buffer Compiler Installation documentation.
You can also use your package manager (e.g. brew install protobuf on macOS).
Go the releases page, and download the protoc-gen-twirpy binary for your platform.
Unzip the archive and move the binary to a directory in your PATH.
On macOS, you can use the following commands:
curl -L -o- \
https://github.com/Cryptact/twirpy/releases/latest/download/protoc-gen-twirpy-darwin-arm64.tar.gz \
| tar xz -C ~/.local/bin protoc-gen-twirpy
Generate and run
Use the protoc plugin to generate twirp server and client code.
protoc --python_out=. --pyi_out=. --twirpy_out=. example/rpc/haberdasher/service.proto
For more information on how to generate code, see the example.
Development
We use hatch to manage the development process.
To open a shell with the development environment, run: hatch shell.
To run the linter, run: hatch fmt --check or hatch fmt to fix the issues.
To run the type checker, run: hatch run types:check.
Standing on the shoulders of giants
- The initial version of twirpy was made from an internal copy of https://github.com/daroot/protoc-gen-twirp_python_srv
- The work done by Verloop on the initial versions of Twirpy.
- The
run_in_threadpoolmethod comes from https://github.com/encode/starlette
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
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 twirpy-0.3.0.dev3.tar.gz.
File metadata
- Download URL: twirpy-0.3.0.dev3.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81e9d39186e3d4cfabbd3217f1a953a1e64f45a1e0e26e2fd8e96c1e2f7ffd7
|
|
| MD5 |
0e7993bce5bf47422d843836df728aed
|
|
| BLAKE2b-256 |
4c87d35766799aab3bac783d34580adabab107e0372aa2de1d44a0b8378f80ca
|
Provenance
The following attestation bundles were made for twirpy-0.3.0.dev3.tar.gz:
Publisher:
python-publish.yml on Cryptact/twirpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twirpy-0.3.0.dev3.tar.gz -
Subject digest:
b81e9d39186e3d4cfabbd3217f1a953a1e64f45a1e0e26e2fd8e96c1e2f7ffd7 - Sigstore transparency entry: 1249119926
- Sigstore integration time:
-
Permalink:
Cryptact/twirpy@8bba1a2e98caf1398d36b47db11123be2962ef92 -
Branch / Tag:
refs/tags/twirpy/0.3.0-dev.3 - Owner: https://github.com/Cryptact
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8bba1a2e98caf1398d36b47db11123be2962ef92 -
Trigger Event:
release
-
Statement type:
File details
Details for the file twirpy-0.3.0.dev3-py3-none-any.whl.
File metadata
- Download URL: twirpy-0.3.0.dev3-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53af83142c1bda311344c20b495fc0c29486da29aa4c76c4e0a4323f98ff2374
|
|
| MD5 |
5888201243c889afcfedecd8167e9b1f
|
|
| BLAKE2b-256 |
0d23121bbd115bedbb32fae7db541a1f0e35ea1cdd4bcb31bddf35722532e069
|
Provenance
The following attestation bundles were made for twirpy-0.3.0.dev3-py3-none-any.whl:
Publisher:
python-publish.yml on Cryptact/twirpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twirpy-0.3.0.dev3-py3-none-any.whl -
Subject digest:
53af83142c1bda311344c20b495fc0c29486da29aa4c76c4e0a4323f98ff2374 - Sigstore transparency entry: 1249120030
- Sigstore integration time:
-
Permalink:
Cryptact/twirpy@8bba1a2e98caf1398d36b47db11123be2962ef92 -
Branch / Tag:
refs/tags/twirpy/0.3.0-dev.3 - Owner: https://github.com/Cryptact
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8bba1a2e98caf1398d36b47db11123be2962ef92 -
Trigger Event:
release
-
Statement type: