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.8.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.8.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.8.0
File Actions
xrack-0.8.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for xrack-0.8.0-cp311-abi3-win_arm64.whl
xrack-0.8.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for xrack-0.8.0-cp311-abi3-win_amd64.whl
xrack-0.8.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.8.0-cp311-abi3-manylinux_2_28_x86_64.manylinux_2_39_x86_64.whl
xrack-0.8.0-cp311-abi3-manylinux_2_28_aarch64.manylinux_2_39_aarch64.whl CPython 3.11 abi3 Linux glibc 2.39+ ARM64, Linux glibc 2.28+ ARM64 Details for xrack-0.8.0-cp311-abi3-manylinux_2_28_aarch64.manylinux_2_39_aarch64.whl
xrack-0.8.0-cp311-abi3-macosx_13_0_arm64.whl CPython 3.11 abi3 macOS 13.0+ ARM64 Details for xrack-0.8.0-cp311-abi3-macosx_13_0_arm64.whl

Total release size: 71.9 MB

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

Download URL xrack-0.8.0-cp311-abi3-win_arm64.whl
Size 11.4 MB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
80b0483feed47e481e11f0c30bf66a1d1ff81121d83ac5f9f31523b19974bfb9
BLAKE2b-256 checksum
How to use checksums
3348d53c13ea757ade4c390fad2bf06094091b5f8b57fda8e838809141e57841
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 20, 2026.

Transparency log

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

Download URL xrack-0.8.0-cp311-abi3-win_amd64.whl
Size 12.2 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8f78f302076d1ddbe00a26331d7fe1326390a64b66addf11c6d7eb16cdb63f75
BLAKE2b-256 checksum
How to use checksums
1209ac867d49428f981fb3915687394d9b441424d9c6e26289d2f2d023ea0c9c
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 20, 2026.

Transparency log

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

Download URL xrack-0.8.0-cp311-abi3-manylinux_2_28_x86_64.manylinux_2_39_x86_64.whl
Size 17.7 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
4d2a652a3ef3e259386ae5b27227206ce48fcd1400c5e5b3207e4f0f401baa01
BLAKE2b-256 checksum
How to use checksums
a8f06622336291b29b35596ac983101435c1602b7071f6318f8a8b4f69f1db06
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 20, 2026.

Transparency log

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

Download URL xrack-0.8.0-cp311-abi3-manylinux_2_28_aarch64.manylinux_2_39_aarch64.whl
Size 17.6 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 Linux glibc 2.39+ ARM64 abi3
SHA-256 checksum
How to use checksums
5945cc24bc357bca1a81f3bb24e7a9ac474c62a6e754c80a04afd6f8d9a482a3
BLAKE2b-256 checksum
How to use checksums
6fe8a7bfef96b8af2439e76d20adc85f3f64d25e12999c0e59ee56cbbc476f59
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 20, 2026.

Transparency log

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

Download URL xrack-0.8.0-cp311-abi3-macosx_13_0_arm64.whl
Size 12.8 MB
Tags CPython 3.11 abi3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
c62980ad5276fd6fbedde0e8bd4321290ea066f22308a9d1e921d4cfb220fbe4
BLAKE2b-256 checksum
How to use checksums
1f72db8c1d7614d88c8be1d800b3be66f258324ef57a0fa1a649b799e8dc2635
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 20, 2026.

Transparency log

Security for xrack 0.8.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.8.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 20, 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