Skip to main content

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.

-- Twirp's README

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

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

twirpy-0.3.0.dev2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twirpy-0.3.0.dev2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file twirpy-0.3.0.dev2.tar.gz.

File metadata

  • Download URL: twirpy-0.3.0.dev2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for twirpy-0.3.0.dev2.tar.gz
Algorithm Hash digest
SHA256 a7b2d4d2bd4af151dcfa56eb5a1dacbb9d826f439dbd137e6561e10284feb5fd
MD5 bba2dca84c33b454f60cd6585ef0156b
BLAKE2b-256 1078bdab40d6d2cf133d784d0542ba85c034246aa2ff25bf5ab84a53eb057bb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for twirpy-0.3.0.dev2.tar.gz:

Publisher: python-publish.yml on Cryptact/twirpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file twirpy-0.3.0.dev2-py3-none-any.whl.

File metadata

  • Download URL: twirpy-0.3.0.dev2-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.12.9

File hashes

Hashes for twirpy-0.3.0.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 c49e1ba72a6e8d1bcdbd617af4abe9c527143d31910c3916ca2382cd1d2e943b
MD5 122d011567b5b58d92376ba015023c8b
BLAKE2b-256 143ba1125ee8a0c6481a027407bdd5658d2d513afafb73ab3660801626708b29

See more details on using hashes here.

Provenance

The following attestation bundles were made for twirpy-0.3.0.dev2-py3-none-any.whl:

Publisher: python-publish.yml on Cryptact/twirpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page