Skip to main content

Plasmite Python Bindings (v0)

These bindings wrap the libplasmite C ABI via ctypes.

Installation

Published wheels bundle native assets under plasmite/_native/ on the platforms where wheels are currently shipped:

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

Current packaged-wheel targets:

  • macOS: x86_64, arm64
  • Windows: x86_64

Linux currently falls back to source distribution, so runtime use there should come from a system SDK install (for example Homebrew or a GitHub release tarball) unless/until Linux wheels are added.

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.

Pools have bounded retention. A tail normally resumes at the next retained message if writes overtake it. Set error_on_gap=True when the consumer must distinguish that loss from an ordinary lack of matching messages:

from plasmite import RetentionGapError

try:
    for item in pool.tail(since_seq=last_seq + 1, error_on_gap=True):
        process(item)
except RetentionGapError as err:
    print(f"rebuild required; first missing sequence: {err.seq}")

Error behavior

  • Invalid local arguments raise ValueError / TypeError.
  • ABI/runtime failures raise typed subclasses of PlasmiteError (NotFoundError, AlreadyExistsError, BusyError, PermissionDeniedError, CorruptError, IoError, UsageError, InternalError, RetentionGapError).
  • 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.

Threads and handle ownership

The Python wrapper serializes native operations and close() on each Client, Pool, Stream, and Lite3Stream instance. You can share an instance between threads without racing its native handle or freeing it during a call. Independent handles can operate concurrently. Message values are owned snapshots and can outlive the pool.

Each opened stream owns an independent handle. tail() and replay() release handle locks between reads, including while yielding messages or sleeping for replay timing. Consume each generator from one thread at a time.

close() waits for an active native call to finish; it does not interrupt a blocking stream read. Pass a finite timeout_ms when opening a stream if another thread needs to close it within a bounded wait. A stream without a timeout can keep close() waiting indefinitely.

Metadata

Release files for plasmite 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plasmite 1.1.0
File Size Uploaded
plasmite-1.1.0.tar.gz 25.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for plasmite 1.1.0
File Interpreter ABI Platform
plasmite-1.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
plasmite-1.1.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
plasmite-1.1.0-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details

Total release size: 16.7 MB

Release files / plasmite-1.1.0.tar.gz

Download URL plasmite-1.1.0.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
478884078e2478fd34c22bb915fc43e476fd900538225f4bb78d95332ca31416
BLAKE2b-256 checksum
How to use checksums
77d4852713202a81bac257a414f284a996c30d56a494847dbfd03be3ab660960
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / plasmite-1.1.0-cp311-cp311-win_amd64.whl

Download URL plasmite-1.1.0-cp311-cp311-win_amd64.whl
Size 5.4 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
7a1f56beea1c5c3fc57e7104b4ba26c40d702b061459685e26c0296c7a4bb08a
BLAKE2b-256 checksum
How to use checksums
56ba1918cd84baa297f7d43ed872d593ee324ac9ed7bfd60298d6a38b609fc4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / plasmite-1.1.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL plasmite-1.1.0-cp311-cp311-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bcb0b192081338b9f41a578b56b3842fdd297dde37e18e02d3eb7bde98da9ed3
BLAKE2b-256 checksum
How to use checksums
d965e2fad71ef10981a9820f6afd30b549175e66ce5956f6b28506ad70470200
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / plasmite-1.1.0-cp311-cp311-macosx_10_12_x86_64.whl

Download URL plasmite-1.1.0-cp311-cp311-macosx_10_12_x86_64.whl
Size 5.8 MB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e46da6af03bbfd98e5a073955015918a1efce11a92d917f62dcbf7a7c7adc983
BLAKE2b-256 checksum
How to use checksums
fbab71e7a77e75b260b74fc8dadc06b3d7492c8c765dff598676574ff2310eab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.1.0 This release

4 release files

1.0.0

4 release files

0.8.0

4 release files

0.7.2

4 release files

0.7.1

4 release files

0.7.0

4 release files

0.6.1

4 release files

0.6.0

4 release files

0.5.1

4 release files

0.5.0

4 release files

0.3.0

4 release files

0.2.0

4 release files

0.1.14

3 release files

0.1.13

3 release files

0.1.9

3 release files

0.1.8

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page