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 loadingplasmiteCLI 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.
Using uv (recommended)
uv tool install plasmite
For project dependencies in a uv-managed workspace:
uv add plasmite
Runtime load order is:
PLASMITE_LIB_DIRoverride (development escape hatch)- Bundled
plasmite/_native/libplasmite.(dylib|so)absolute path - System linker fallback (
plasmite/libplasmite)
For development/testing from this repo, see Install & Test below.
Build Requirements
- Python 3.10+
libplasmitebuilt 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
PlasmiteErrorvalues exposekind,path,seq, andoffsetwhen present.
Troubleshooting
- Missing pool directory: pool creation creates parent directories automatically. If you call
open_pool(...)on a missing pool, catchNotFoundErroror useclient.pool(...)to create-or-open. - Permission denied: choose a writable pool directory (
Client("/path/to/pools")) and verify directory permissions/ownership. Errors includeerr.pathwhen 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.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| plasmite-1.0.0.tar.gz | 23.9 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| plasmite-1.0.0-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| plasmite-1.0.0-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
| plasmite-1.0.0-cp311-cp311-macosx_10_12_x86_64.whl | CPython 3.11 | CPython 3.11 | macOS 10.12+ x86-64 | Details |
Total release size: 34.6 MB
Release files / plasmite-1.0.0.tar.gz
| Download URL | plasmite-1.0.0.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b84366af67e3ab1070968f5d819716be3c76a288b61bbc456f9734952b4228dd
|
|
BLAKE2b-256 checksum How to use checksums |
a5603d5031ec918ca0145faee14037a8bcceb9d50775a0072ae3464c3a9b6bb0
|
| 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.0.0-cp311-cp311-win_amd64.whl
| Download URL | plasmite-1.0.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3f3ff8edc0380429f8098b6d2afd306139105068acca18d8c690282dc41cf643
|
|
BLAKE2b-256 checksum How to use checksums |
a00cf0a70fd927ac479e5844e234219811587b9f28139476715171bd8d14b199
|
| 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.0.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | plasmite-1.0.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 14.5 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
25b518876a853974c1ea068f43ea06c7c803936c1fa6a9a1656963b5c3fdb687
|
|
BLAKE2b-256 checksum How to use checksums |
b5922a5906e3fc052f8fb3d5cd7dc2a2763f585bd320e88cbda4c296510e8f91
|
| 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.0.0-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | plasmite-1.0.0-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 14.9 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
361d570b87f57b3ecb8c42c35cc4cf99b81106b6eef31d7bcc5a719ad24dc2d9
|
|
BLAKE2b-256 checksum How to use checksums |
102a389c2f22b6898aa3e2b39b6a6abfabab69da2734b1d03842e714a7ad1430
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|