Skip to main content

Persistent JSON message queues for Python - native bindings for local and remote IPC

Project description

Plasmite Python Bindings (v0)

These bindings wrap the libplasmite C ABI via ctypes.

Installation

Wheels are designed to bundle native assets under plasmite/_native/:

  • libplasmite.(dylib|so) for ctypes loading
  • plasmite CLI binary (invoked via Python console script entrypoint)

Using uv (recommended)

uv tool install plasmite

For project dependencies in a uv-managed workspace:

uv add plasmite

Runtime load order is:

  1. PLASMITE_LIB_DIR override (development escape hatch)
  2. Bundled plasmite/_native/libplasmite.(dylib|so) absolute path
  3. System linker fallback (plasmite / libplasmite)

For development/testing from this repo, see Install & Test below.

Build Requirements

  • Python 3.10+
  • libplasmite built from this repo (cargo build -p plasmite) for local development

Install & Test

From the repo root:

cargo build -p plasmite

Canonical repo-root command:

just bindings-python-test

Equivalent manual commands (from bindings/python):

uv venv
source .venv/bin/activate
PLASMITE_LIB_DIR="$(pwd)/../../target/debug" uv pip install -e .
PLASMITE_LIB_DIR="$(pwd)/../../target/debug" PLASMITE_BIN="$(pwd)/../../target/debug/plasmite" python3 -m unittest discover -s tests

Build a wheel with bundled native assets from a specific SDK directory:

PLASMITE_SDK_DIR=/path/to/sdk python -m build

Conformance runner (manifest parity with Rust/Go/Node):

cargo build -p plasmite
cd bindings/python
PLASMITE_LIB_DIR="$(pwd)/../../target/debug" \
PLASMITE_BIN="$(pwd)/../../target/debug/plasmite" \
python3 cmd/plasmite_conformance.py ../../conformance/sample-v0.json

Usage

from plasmite import Client, Durability, NotFoundError

with Client("./data") as client:
    with client.pool("docs", 64 * 1024 * 1024) as pool:
        msg = pool.append({"kind": "note", "text": "hi"}, ["note"], Durability.FAST)
        print(msg.seq, msg.tags, msg.data["text"])

        fetched = pool.get(msg.seq)
        print(fetched.data["text"])

        for item in pool.tail(tags=["note"], max_messages=1, timeout_ms=100):
            print(item.seq, item.tags, item.data)

    try:
        client.open_pool("missing")
    except NotFoundError:
        print("pool not found")

Pool.append(...), Pool.get(...), Pool.tail(...), and Pool.replay(...) return typed Message values by default.

Use append_json(...) / get_json(...) only when you explicitly need raw wire bytes.

Pool.tail(..., tags=[...]) uses exact tag matching and composes with other filters using AND semantics.

Error behavior

  • Invalid local arguments raise ValueError / TypeError.
  • ABI/runtime failures raise typed subclasses of PlasmiteError (NotFoundError, AlreadyExistsError, BusyError, PermissionDeniedError, CorruptError, IoError, UsageError, InternalError).
  • All PlasmiteError values expose kind, path, seq, and offset when present.

Troubleshooting

  • Missing pool directory: pool creation creates parent directories automatically. If you call open_pool(...) on a missing pool, catch NotFoundError or use client.pool(...) to create-or-open.
  • Permission denied: choose a writable pool directory (Client("/path/to/pools")) and verify directory permissions/ownership. Errors include err.path when available.

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

plasmite-0.6.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distributions

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

plasmite-0.6.1-cp311-cp311-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.11Windows x86-64

plasmite-0.6.1-cp311-cp311-macosx_11_0_universal2.whl (5.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ universal2 (ARM64, x86-64)

plasmite-0.6.1-cp311-cp311-macosx_10_12_universal2.whl (6.0 MB view details)

Uploaded CPython 3.11macOS 10.12+ universal2 (ARM64, x86-64)

File details

Details for the file plasmite-0.6.1.tar.gz.

File metadata

  • Download URL: plasmite-0.6.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for plasmite-0.6.1.tar.gz
Algorithm Hash digest
SHA256 03bc67422ece2eb430c9cb99cdd4986829c611b38c1c87dd2fa3c3b6b8a87b4f
MD5 a160cb95c7a6b43519575c0ed164d6aa
BLAKE2b-256 a2b6dbb2b1b983a71413b5b4150967a4d5f4025f1c4fd5b57a7b0c2532d7a111

See more details on using hashes here.

File details

Details for the file plasmite-0.6.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: plasmite-0.6.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for plasmite-0.6.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 19e74f50105fafbb3d977484bfcb745004f3d3e966f7e866cf86909d8e52648d
MD5 f123b211cd5c0faa780f9ae5a3e096c7
BLAKE2b-256 aad70d30f3792f1d57965b9c53f77d80057c27c286fcd112c90b47f9c65992f0

See more details on using hashes here.

File details

Details for the file plasmite-0.6.1-cp311-cp311-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for plasmite-0.6.1-cp311-cp311-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 0d6a81361d7e6211b469f12b73110b95f6adf14332b1ebf890aad374916918b7
MD5 273be030e86a1ac001cf00f380dc035b
BLAKE2b-256 6ed32a6d117ff2a3fb04d06d505dc3a12b634ce2c001eaba4cd0973c52ccf635

See more details on using hashes here.

File details

Details for the file plasmite-0.6.1-cp311-cp311-macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for plasmite-0.6.1-cp311-cp311-macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 076b6815d63e0c582a4a2c0e379e1d5811ed270a59d315393e480fdf3feb209c
MD5 31fd45f4f7ee1b7711cff98dd73e0539
BLAKE2b-256 b49856be2a3fef637dce75467a7d8c08d1b44f10432722df38262ea61d00b9ea

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