pyroh
A friendly, asyncio-like Python wrapper for iroh.
Pyroh wraps iroh's rust bindings via pyo3 and integrates with asyncio using the standard StreamReader/StreamWriter interface.
Requirements
- Python ≥ 3.14
Installation
pip install pyroh
To build from source:
maturin develop
Quickstart
import asyncio
import pyroh
ALPN = b"myapp/1"
async def handle_connection(conn: pyroh.Connection) -> None:
reader, writer = await conn.accept_bi()
data = await reader.read(1024)
print(f"server got: {data!r}")
writer.write(b"hello back")
writer.close()
await writer.wait_closed()
async def main():
# Bind a server endpoint. A fresh keypair is generated automatically.
server = await pyroh.Endpoint.bind(alpns=[ALPN])
async with server:
srv = server.start_server(handle_connection)
# Bind a client endpoint and connect by full address or ticket.
# By default, this hangs until the endpoint is online.
# You can disable this behavior by doing
# `endpoint = await pyroh.Endpoint.bind(wait_online=False)`
# and then awaiting `endpoint.wait_online()` later
client = await pyroh.Endpoint.bind(alpns=[ALPN])
async with client:
conn = await client.connect(server.ticket, alpn=ALPN)
async with conn:
reader, writer = await conn.open_bi()
writer.write(b"hello")
writer.close()
response = await reader.read(1024)
print(f"client got: {response!r}")
srv.close()
asyncio.run(main())
You can view more examples in the examples folder
API
pyroh.Endpoint
The main entry point. Represents a local QUIC endpoint.
endpoint = await pyroh.Endpoint.bind(
alpns=[b"myapp/1"], # ALPNs to accept; default is [b"pyroh/1"]
key=None, # 32-byte secret key, or None to generate a fresh one
wait_online=True, # if False, return immediately and call wait_online() manually
)
Properties
| Property | Type | Description |
|---|---|---|
id |
str |
Node ID (public key) as a hex string. Requires discovery to connect directly. |
addr |
EndpointAddr |
Full endpoint address (node ID + relay/direct addresses). Use this without discovery. |
ticket |
str |
Serialized endpoint ticket for sharing full address info. |
secret_key |
bytes |
The 32-byte secret key for this endpoint's identity. Store it to reuse the same node ID across restarts. |
Methods
| Method | Description |
|---|---|
await endpoint.connect(addr, *, alpn=b"pyroh/1") |
Connect to a remote peer by node ID, EndpointAddr, or endpoint ticket string. Returns a Connection. |
endpoint.start_server(handler) |
Start accepting connections, calling handler(conn) for each one. Returns a Server. |
await endpoint.wait_online() |
Wait until the endpoint has contacted a relay and is reachable. Only needed when bind(wait_online=False) was used. |
endpoint.set_alpns(alpns) |
Update the set of accepted ALPNs at runtime (e.g. for protocol upgrades). |
await endpoint.close() (or async with endpoint) |
Shut down the endpoint. |
pyroh.EndpointAddr
Represents full dial information (node ID + optional relay/direct addresses).
Class methods
| Method | Description |
|---|---|
EndpointAddr.from_json(raw) |
Parse full address info from JSON (e.g. Endpoint.addr_json). |
EndpointAddr.from_id(node_id) |
Create an ID-only address (discovery required). |
EndpointAddr.from_ticket(ticket) |
Parse a serialized endpoint ticket into full address info. |
pyroh.Connection
A QUIC connection to a remote peer. Connections multiplex streams — open as many as you need without the overhead of new connections.
Methods
| Method | Description |
|---|---|
await conn.open_bi() |
Open a bidirectional stream. Returns (StreamReader, StreamWriter). |
await conn.accept_bi() |
Accept a bidirectional stream opened by the remote. Returns (StreamReader, StreamWriter). |
await conn.open_uni() |
Open a send-only stream. Returns StreamWriter. |
await conn.accept_uni() |
Accept a receive-only stream opened by the remote. Returns StreamReader. |
await conn.abort(error_code=0, reason="") |
Forcefully close the connection with an application error code. |
conn.close() |
Close all open streams on this connection. |
async with conn |
Context manager — calls close() and wait_closed() on exit. |
pyroh.Server
Returned by endpoint.start_server(handler). Accepts connections in a background task.
| Method | Description |
|---|---|
await server.serve_forever() |
Block until the server is closed (e.g. from a signal handler). |
server.close() |
Stop accepting new connections. Does not close the underlying endpoint. |
server.id |
Node ID of the underlying endpoint (same as endpoint.id). |
Metadata
Release files for pyroh 0.4.2
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 | |
|---|---|---|---|---|
| pyroh-0.4.2.tar.gz | 48.1 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyroh-0.4.2-cp314-abi3-win_arm64.whl | CPython 3.14 | abi3 | Windows ARM64 | Details |
| pyroh-0.4.2-cp314-abi3-win_amd64.whl | CPython 3.14 | abi3 | Windows x86-64 | Details |
| pyroh-0.4.2-cp314-abi3-musllinux_1_2_x86_64.whl | CPython 3.14 | abi3 | Linux musl 1.2+ x86-64 | Details |
| pyroh-0.4.2-cp314-abi3-musllinux_1_2_aarch64.whl | CPython 3.14 | abi3 | Linux musl 1.2+ ARM64 | Details |
| pyroh-0.4.2-cp314-abi3-manylinux_2_28_x86_64.whl | CPython 3.14 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| pyroh-0.4.2-cp314-abi3-manylinux_2_28_aarch64.whl | CPython 3.14 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| pyroh-0.4.2-cp314-abi3-macosx_11_0_arm64.whl | CPython 3.14 | abi3 | macOS 11.0+ ARM64 | Details |
| pyroh-0.4.2-cp314-abi3-macosx_10_12_x86_64.whl | CPython 3.14 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 58.5 MB
Release files / pyroh-0.4.2.tar.gz
| Download URL | pyroh-0.4.2.tar.gz |
|---|---|
| Size | 48.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8f6e567cc24d9a924b31688032b6e59376379c1d0e094fa83175062ede29162
|
|
BLAKE2b-256 checksum How to use checksums |
1661dfc0214a9dc428303cd61cda112053f403b7e646583c22927a5df8b4bf1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-win_arm64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-win_arm64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.14 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
1cef294fa3cd8ca1c9336b1be5870c258930bc184a0b3727b5d9bee8b04def12
|
|
BLAKE2b-256 checksum How to use checksums |
f5ad556e3068f3b75d98d6cee80fe0fb68c7be6dd79212c3fcbee23423c8cd1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-win_amd64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-win_amd64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.14 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ba19c19be4399c2702ab8ffb09d40e72aa0b4ec168b1ae6995cb0209c223ad79
|
|
BLAKE2b-256 checksum How to use checksums |
6b197fa8419314584ac6b9adac091eb0596bddca39b778823fd961b5cb74214e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-musllinux_1_2_x86_64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 8.5 MB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1f9a226bf76411bd4fe7eff97365a9e798ad7025ec664861da4618cca802b6ba
|
|
BLAKE2b-256 checksum How to use checksums |
5b3fb54e143a769edd0fc1ea2edd02c64f8e37bbed5bdc86f994ceb586a017a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-musllinux_1_2_aarch64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.14 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
4d398aceb1f6208320753d3c77ac8deb13638224a48c9596d3a8f031abaf426e
|
|
BLAKE2b-256 checksum How to use checksums |
6a5976d5c86fa636d1b1b402e60a809141785cb2e70a3f388a04d817dc78f43e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-manylinux_2_28_x86_64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.1 MB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3d8876dd9d558c691ff4fd135980a6208b1b3ddbcd33d1d9f13c762151df1f7e
|
|
BLAKE2b-256 checksum How to use checksums |
6ae210bd1195f027765f226bd960b1bbee8bad6b4335ae814aa1f4ff4b1dee03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-manylinux_2_28_aarch64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.2 MB |
| Tags | CPython 3.14 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d9d7aa83ba63c614a2ed467225ac4f05bb534331d52856e3dd18e1d9a223e151
|
|
BLAKE2b-256 checksum How to use checksums |
3e16248ea8323e8448ae8c7730c599c1ad4b73f41de81b6fc412272bcec6cf14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-macosx_11_0_arm64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.14 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
36a5acbb3a3c6dbe886cd69e47e7fcafce0c2476e759bce9a27a5f1e39d7950d
|
|
BLAKE2b-256 checksum How to use checksums |
f5b296bb55a06b891f8c0b31e3fcca07e50c1a7004a4d497729d0faee93db7b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyroh-0.4.2-cp314-abi3-macosx_10_12_x86_64.whl
| Download URL | pyroh-0.4.2-cp314-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.14 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3481532780b4fd3b9cf6de5dc78758a13aa7350ed053568c3502f53ff11ab319
|
|
BLAKE2b-256 checksum How to use checksums |
5407037f6a2014297405aef1d68657918c969a7c5cfb2340d6b96d990c46c097
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pyroh 0.4.2
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.