Skip to main content

XRack Python bindings

load_file(path) compiles an .xr file and resolves its imports and assets. load_mlir_file(path) loads exported XRack MLIR and its file resources. Call program.create(name) to instantiate an exported component.

The Python API reads and writes public properties with get and set, restores declarative bindings with reset, and exposes callbacks through on and invoke. Coroutine handlers can be connected to void callbacks.

Public values include Python scalars and string lists, plus XRack types for lengths and percentages, colors and brushes, dates, times, fonts, styled text, images, records, input events and enums. The same types are used for property values and callback arguments and results.

ui.set("accent", xrack.Color.from_hex("#536dfe"))
ui.set("spacing", xrack.Length(12))
ui.set("direction", xrack.LayoutDirection.RightToLeft)

ui.get("names") returns a string-list snapshot. ui.string_model("names") gives you the live model of a writable list. Use ui.record_model("rows") to append, replace, or delete individual records. A replacement keeps the row identity. XRack validates a new row against the schema before writing it. ui.get("rows") remains a snapshot.

Use the live models and UI-owned values such as images and records on the main thread. From a coroutine, pass plain data back and construct or inspect these values inside call_on_ui.

Run the existing asynchronous search UI with Python business logic:

bazel run //bindings/python:async_demo

Call ui.run() on Python's main thread. XRack owns the native window there and runs a standard asyncio loop on a dedicated Python thread. Synchronous callbacks run on the main thread. Coroutine handlers can use asyncio.sleep, asyncio.open_connection, and asyncio.to_thread. Use await ui.call_on_ui(ui.set, "loading", True) to make a UI change from a coroutine. The native binding uses pyo3-async-runtimes to return the result or exception to the caller's event loop. You can also pass an async startup function to ui.run(main).

Closing the last window cancels outstanding asyncio tasks and waits for their cleanup. Coroutine cancellation is cooperative. Work already running in asyncio.to_thread follows Python's executor shutdown behavior. Start the native event loop once per process.

Use ui.on_request("search", search, publish) when a coroutine produces a result for the UI. The .xr callback is declared without a return value. The Python search coroutine can return any Python value accepted by publish, and only the latest request for that callback applies its result. Optional on_start and on_error hooks run on the UI thread, along with publish. See the asynchronous search example for how to update the loading state.

Use await ui.invoke_async("result-label", item) from a Python coroutine to retrieve an immediate XRack callback result. If the callback starts an asynchronous handler, the await finishes after the callback schedules the handler.

Build a native wheel with bazel build //bindings/python:wheel. Bazel generates xrack/_native.pyi from the native binding and includes it and py.typed in the wheel. For example, install the macOS ARM64 build as follows:

bazel build //bindings/python:wheel
python3.11 -m venv /tmp/xrack-python-venv
/tmp/xrack-python-venv/bin/pip install bazel-bin/bindings/python/xrack-0.9.0-cp311-abi3-macosx_13_0_arm64.whl
/tmp/xrack-python-venv/bin/python bindings/python/async_demo.py examples/async_demo/async.xr

From an installed package, run python -m xrack.stubgen ui/async.xr -o async_ui.pyi. This writes async_ui.py and async_ui.pyi together. Import AsyncDemo from async_ui to use typed properties such as ui.query and typed callback registration such as ui.on_search(handler). Re-run the generator after changing the component's public API.

Open the Python example as a reloadable application with bazel run //bindings/python:async_demo -- --live --project "$PWD". You can also pass live=True to xrack.load_file or to a generated component constructor. On Unix, open the project directory in VS Code and run XRack: Sync Editor to Running App to attach.

Format Python sources with bazel run //bindings/python:format -- <files>.

Run the binding tests with bazel test //bindings/python:binding_test. On a desktop session, run bazel test //bindings/python:window_test to exercise an actual window, and add --test_arg=--close-early to test cancellation.

PyPI releases

The Python workflow builds CPython 3.11+ wheels for macOS ARM64, Linux ARM64 and x86-64, and Windows ARM64 and x86-64. The macOS wheel targets macOS 13 or later. Linux wheels are repaired and checked for the manylinux glibc 2.39 baseline. Each job installs its wheel into a clean virtual environment and runs the binding tests.

A stable version tag on main publishes the five verified wheels. The tag must match the workspace version and the wheel version. For the first release, configure a PyPI pending publisher for the distribution xrack with owner smallsunsun1, repository xrack, workflow python.yml, and GitHub environment pypi.

Metadata

Release files for xrack 0.9.0

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

Built distributions (wheels)

Table of built distributions (wheels) for xrack 0.9.0
File Actions
xrack-0.9.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for xrack-0.9.0-cp311-abi3-win_arm64.whl
xrack-0.9.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for xrack-0.9.0-cp311-abi3-win_amd64.whl
xrack-0.9.0-cp311-abi3-manylinux_2_28_x86_64.manylinux_2_39_x86_64.whl CPython 3.11 abi3 Linux glibc 2.39+ x86-64, Linux glibc 2.28+ x86-64 Details for xrack-0.9.0-cp311-abi3-manylinux_2_28_x86_64.manylinux_2_39_x86_64.whl
xrack-0.9.0-cp311-abi3-manylinux_2_28_aarch64.manylinux_2_39_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.39+ ARM64 Details for xrack-0.9.0-cp311-abi3-manylinux_2_28_aarch64.manylinux_2_39_aarch64.whl
xrack-0.9.0-cp311-abi3-macosx_13_0_arm64.whl CPython 3.11 abi3 macOS 13.0+ ARM64 Details for xrack-0.9.0-cp311-abi3-macosx_13_0_arm64.whl

Total release size: 103.3 MB

Release files / xrack-0.9.0-cp311-abi3-win_arm64.whl

Download URL xrack-0.9.0-cp311-abi3-win_arm64.whl
Size 16.9 MB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
cc112f073017b5f4871682e9def535ed74c16542b78cb09013491847da826e20
BLAKE2b-256 checksum
How to use checksums
64c0dd4e388f76071fac92dedc5aebdc41d3fda34c93c681ca9076ff05e43bfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / xrack-0.9.0-cp311-abi3-win_amd64.whl

Download URL xrack-0.9.0-cp311-abi3-win_amd64.whl
Size 18.0 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a147473d3b7a47f5aae51e34beed70978dd37c326fd291c89e53e9b45da78834
BLAKE2b-256 checksum
How to use checksums
d3409837912f0b73f4071764cc91bb4af4d1afdd8874a2c6b40b030b5d188004
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / xrack-0.9.0-cp311-abi3-manylinux_2_28_x86_64.manylinux_2_39_x86_64.whl

Download URL xrack-0.9.0-cp311-abi3-manylinux_2_28_x86_64.manylinux_2_39_x86_64.whl
Size 24.8 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 Linux glibc 2.39+ x86-64 abi3
SHA-256 checksum
How to use checksums
987f975eb3a60af6f2663cd738e622341d21132801e70d3355ac15fb10c8b699
BLAKE2b-256 checksum
How to use checksums
093436e5e72c5a9d128ca3c2a86631aa33c7f8bbfc75e83ffc841f7b543b49d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / xrack-0.9.0-cp311-abi3-manylinux_2_28_aarch64.manylinux_2_39_aarch64.whl

Download URL xrack-0.9.0-cp311-abi3-manylinux_2_28_aarch64.manylinux_2_39_aarch64.whl
Size 24.6 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 Linux glibc 2.39+ ARM64 abi3
SHA-256 checksum
How to use checksums
7c56355d4ab369a8dfc21c6f382d373c3ceee4a6239295feb709186b88fc7b2c
BLAKE2b-256 checksum
How to use checksums
e18384c80d00b8dc69c6260bb57dc9165b18c310f2e9c2b75b9b6cdbd2e4fea7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / xrack-0.9.0-cp311-abi3-macosx_13_0_arm64.whl

Download URL xrack-0.9.0-cp311-abi3-macosx_13_0_arm64.whl
Size 19.0 MB
Tags CPython 3.11 abi3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
6cfbc8ad646c1389c50760f2fc3a713564b8188888d0130c6ddc5ffd1dba6f6d
BLAKE2b-256 checksum
How to use checksums
67579b6829f88dcecbbeadef9f3c39ae37c319198b40c7aa0e7c14880d41d390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for xrack 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for xrack-0.9.0-cp311-abi3-win_arm64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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