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.

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.1.0.dev4.tar.gz (9.3 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.1.0.dev4-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file twirpy-0.1.0.dev4.tar.gz.

File metadata

  • Download URL: twirpy-0.1.0.dev4.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for twirpy-0.1.0.dev4.tar.gz
Algorithm Hash digest
SHA256 d9ce28f461c002dbc2a361d570cda681fec221213509df206c445d0cbdfbb038
MD5 08664b3dbaf91a2aff3722509c0951c2
BLAKE2b-256 fec09dfe25d0a55a10b1cebd9f29bdfdba3b14713cc4e7ab380cf7800e963661

See more details on using hashes here.

File details

Details for the file twirpy-0.1.0.dev4-py3-none-any.whl.

File metadata

  • Download URL: twirpy-0.1.0.dev4-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for twirpy-0.1.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 06a75d675af3b38d6b200c0490b82ff2a611def88bb26c4fe87041e99415aaf9
MD5 242f2bdf844f209dd88bada77dff31a0
BLAKE2b-256 40b3d117de337e1ad6f898ef44b518b4a2b21e817684fddca05ce37c011d65dd

See more details on using hashes here.

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