Skip to main content

Python bindings for Forge — hardened infra primitives on Postgres

Project description

forgelib

Python bindings for Forge via pyo3. A natively async ForgeClient over the async Rust core: every method returns an awaitable driven on a shared Tokio runtime, so an asyncio app awaits the binding directly: no thread-pool wrapper, the event loop is never blocked. The full primitive surface is exposed (kv, queue, config, ratelimit, blob, auth, schedule, pubsub), plus backend_report.

Forge errors surface as a typed exception hierarchy (forgelib.NotFoundError, forgelib.InvalidError, forgelib.LimitError, … all subclasses of forgelib.ForgeError), and every raised instance carries a retryable attribute.

Built against the stable ABI (abi3-py39), so one wheel runs on CPython ≥ 3.9. The 1.x release publishes wheels for Linux x64, Linux arm64, macOS arm64, and Windows x64, plus a source distribution. Intel macOS installs from source.

Build

docker compose up -d db          # a Postgres for local use

cd bindings/python
python -m venv .venv && . .venv/bin/activate
pip install maturin
maturin develop                  # compiles + installs `forgelib` into the venv

(On a CPython newer than this pyo3 release knows about, prefix the build with PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1.)

Use

Configuration lives in a forge.toml at the project root; init() reads it and instantiates the runtime. A minimal one:

[postgres]
url = "${DATABASE_URL:-postgres://postgres:forge@localhost:5432/forge_dev}"

[blob]
signing_secret = "${BLOB_SIGNING_SECRET:-dev-secret}"  # enables presigned blob URLs
import forgelib

forge = await forgelib.ForgeClient.init()  # reads ./forge.toml

greeting = forge.kv("greeting")
await greeting.set("hi")
print(await greeting.get())

# Realtime: topic handles decode JSON events for you.
async for event in forge.topic("chat:1").subscribe():
    handle(event)

Native typed handles

The main forgelib package binds names to JSON value types directly on the client, so most app code does not need raw queue strings plus json.dumps:

import forgelib

emails = forge.queue("emails")
await emails.enqueue({"to": "a@b.c", "template": "welcome"}, max_attempts=3)
job = await emails.dequeue(wait_seconds=1.0)
if job:
    handle(job.payload)            # already decoded
    await emails.ack(job.receipt)

profile = forge.kv("user:1:profile")
await profile.set({"name": "Ada"})

The raw methods (kv_set, queue_enqueue, ...) remain available for exact cross-language parity and string/byte contracts. The packaged stubs include both the raw client and the typed handles.

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

forgelib-1.0.0.tar.gz (365.4 kB view details)

Uploaded Source

Built Distributions

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

forgelib-1.0.0-cp39-abi3-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

forgelib-1.0.0-cp39-abi3-manylinux_2_28_aarch64.whl (5.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

forgelib-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

forgelib-1.0.0-cp39-abi3-macosx_11_0_arm64.whl (5.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file forgelib-1.0.0.tar.gz.

File metadata

  • Download URL: forgelib-1.0.0.tar.gz
  • Upload date:
  • Size: 365.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for forgelib-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9ecaa64e7612275c26e0f810af0292286e65f51371407b2940f6197dce6fa25e
MD5 7af613376988f196c64d6b8c5233c247
BLAKE2b-256 4fd107d32b100c938a1cfee128c25e50ced5f13eff10987e4a6b971b34f5fb37

See more details on using hashes here.

File details

Details for the file forgelib-1.0.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: forgelib-1.0.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for forgelib-1.0.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ab3febc246164e82dfac849ee626041ba2b73ee9455d9b60b8ee0ab3f13cf735
MD5 6ab86415fd306a61833452fd988045b5
BLAKE2b-256 0f1282458275efe0bdf8a6756a95e0ff152d8da342d035657ede00e8a5e2559d

See more details on using hashes here.

File details

Details for the file forgelib-1.0.0-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for forgelib-1.0.0-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 15a5b790885e822717dfaebf3574fd457440a5c951d49d1f9b2cf3f7a3e535e0
MD5 bfdadc99fd5026075c1b8bfb2fbae366
BLAKE2b-256 dceff12ffad8dd4ae42064a18f91fd2c28a9bbc79fce168b2bf8a12c57f3f65c

See more details on using hashes here.

File details

Details for the file forgelib-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for forgelib-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f47f9bb024688542fcdd3be82cec7866371e45c76802febda5363bf0944b71fe
MD5 5c58637dac6e2df7a742204ae0fc5054
BLAKE2b-256 1b251a31b287f39f794b72f86e865bf1c902bb747cdc132d747b3a9ed3114898

See more details on using hashes here.

File details

Details for the file forgelib-1.0.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for forgelib-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58e1e9b252660d2d900150ff327f2e78ef0b114088b63d7e60eef4d78ce8f8c4
MD5 098fc3a96caff5001a0ac3fa9bbca492
BLAKE2b-256 26ed08a38a767397bd4548b0378f9a2824a4d6dc146a9d4e62f7838c48b64521

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