Skip to main content

Bitwire for Python

bitspark-bitwire provides the shared relative-path Wire contract as the Python module bitwire. It requires Python 3.11 or newer and has no runtime dependencies. The package contains typed declarations and supporting values; endpoint runtimes, carriers, codecs and routing helpers belong to implementations.

from bitwire import Message, Receiver, ReturnAddress, Wire


def call(endpoint: Wire, replies: Wire) -> None:
    endpoint.send(
        ["cells", "get"],
        Message(
            {"version": 1, "kind": "request", "id": "request-1", "params": {}},
            return_address=ReturnAddress(replies),
        ),
    )


def listen(endpoint: Wire):
    def receive(path, message):
        print(path, message.frame)

    return endpoint.receive([], Receiver(namespace=True, message=receive))

Wire is a structural Protocol; implementations do not need to inherit from it. send accepts or refuses synchronously; the implementation schedules delivery. Receivers may return an awaitable. receive returns an idempotent detach function. Paths are sequences of opaque Unicode-scalar strings and retain empty segments. Receiver paths are relative to the Wire on which they registered.

ReturnAddress uses object identity, including when its Wire cannot be compared or hashed. Preserve this object during routing. The return address is local capability data and must never be serialized into the profile envelope. Profile payloads must follow the JSON profile despite their Python object annotation. Runtime-owned received context associated with the return identity must survive routing. Application-supplied context or metadata does not establish verified invocation context; that verification remains the runtime's responsibility.

The Wire contract and profile boundary define the behavior. Runtime protocol checks verify only the presence of methods; they cannot establish conformance.

Packaging and checks

From this directory:

python -m pip install -r requirements-dev.txt
python check.py

This builds a source distribution and a wheel from it, verifies the distribution contents, installs the wheel into a temporary virtual environment, and runs both consumer tests and static typing checks against that installed package. The test endpoint is a recording fixture, not a Bitwire runtime or conformance driver.

For release artifacts at a chosen location:

python -m build --outdir dist

Optional PyPI publication

The manual publish-python.yml workflow publishes an existing immutable public release tag. It is separate from the Go/TypeScript release and does not gate that handover. Its default authentication is a PyPI trusted publisher. Configure these fields under the PyPI account's Publishing page for a pending project:

Field Value
PyPI project name bitspark-bitwire
Owner Bitspark
Repository name bitwire
Workflow name publish-python.yml
Environment name pypi

For an existing project, add the same publisher under the project's publishing settings. As a bootstrap fallback, store an API token in the repository or pypi environment secret named PYPI_API_TOKEN, then select api-token when dispatching the workflow from main. Tokens are passed only to publication steps. Revoke the bootstrap token after trusted publishing is configured. The workflow verifies the packaged artifact before upload and installs the published PyPI package afterward.

The binding is adapted from Nightseam's Python Wire declarations at commit 1c63f1c4 under Apache-2.0. See the included LICENSE and NOTICE files.

Release files for bitspark-bitwire 0.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 bitspark-bitwire 0.1.0
File Size Uploaded
bitspark_bitwire-0.1.0.tar.gz 11.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bitspark-bitwire 0.1.0
File Interpreter ABI Platform
bitspark_bitwire-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / bitspark_bitwire-0.1.0.tar.gz

Download URL bitspark_bitwire-0.1.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1e0d92f2aa5de656ad5c4a92c2ad15ba7d7d84d830296850864accccecdbbd40
BLAKE2b-256 checksum
How to use checksums
6aada2e881e7c3982a65211dca839e67464d8622f1076b97ebfa792eb987859e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / bitspark_bitwire-0.1.0-py3-none-any.whl

Download URL bitspark_bitwire-0.1.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8c03682be6dc4ccec41deaf8cc42cf48b3f41b3243ce4ebcd9fac98b94272bb
BLAKE2b-256 checksum
How to use checksums
3e93befc013019e5b763a33a3079fa729d9019c034d79235b9bd244974f5308b
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

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 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