gpui-python-runtime
Retained scene specifications for the GPUI Python wrapper.
Python declares UI and scene3d objects. Rust validates the scene, tracks
stable ids, classifies dirty resources, and adapts supported nodes to
gpui-d3rs 3D elements. Raw wgpu devices, queues, buffers, pipelines, and
shaders remain private to the renderer.
Scene3D Scope
- Surfaces: row-major
zgrids with optionalx/yaxes, log axes, z range, labels, colormaps, wireframe mode, orbit cameras, and interactions. - Lines: retained orbit camera state and CPU-projected
Lines3DElementsegments/line strips. - Meshes and surfaces consume retained
ArrayDatageometry and scalar-field resources; materials, perspective cameras, and lights remain declarative scene objects while GPU state stays host-owned.
Audited Python Surface
python-surface.toml is the reviewed Python mapping registry. The generated
python-rustdoc-inventory.json freezes the all-feature macOS public API of the
current priority crates, gpui-d3rs and gpui-px, including inherent methods,
fields, callable parameters, and return types. Run the freshness gate with:
just qa-python-rustdoc-inventory
The gate uses pinned nightly-2026-09-02 rustdoc JSON and rejects public Rust
surface changes until the snapshot is reviewed and regenerated. Inventory
coverage does not itself claim Python parity; stable v2 remains blocked until
every inventory entry has a reviewed binding or exclusion classification.
JSON Schema Contract
Python-authored payloads are versioned at the JSON boundary:
- app IR uses
schema_version: 1, exposed asPYTHON_APP_IR_SCHEMA_VERSION. - Scene3D specs use
schema_version: 1, exposed asSCENE3D_SPEC_SCHEMA_VERSION.
New Python emitters write the current schema version. Rust treats omitted
schema_version fields as v1 so early examples and local scripts keep loading,
but validation rejects unsupported future versions before rendering or reusing a
cached spec.
Compatibility policy:
- Additive optional fields may stay on v1 when Rust gives them safe defaults.
- Renaming fields, removing fields, changing data-shape semantics, or changing renderer meaning requires a schema-version bump.
- A schema-version bump must include compatibility tests for previous v1 payloads and a migration path before Python emitters start writing it.
- Consumers should parse JSON, validate
PythonAppIr, then parse and validate Scene3D specs throughTypedSpecCacheorvalidate_scene3d_spec_schema_version.
Resource Model
RetainedSceneCache fingerprints geometry, material, and camera state
separately:
- unchanged scenes do no renderer work,
- camera-only changes update uniforms/state,
- color/material changes update small renderer state,
- data/mesh changes reupload affected geometry.
Gpui3DCache is available behind the gpui feature and keeps
Surface3DElement / line camera state keyed by stable ids.
Tutorial
New to the Python API? python/tutorial/ walks through
installing the gpui-toolkit wheel and building a native demo app
(demo_app.py: text, metrics, a px line chart, and a button with a live
on_action → patch loop), then points at the larger examples below.
Python Examples
The examples build JSON-serializable scene specs that the Rust runtime can validate and adapt to GPUI elements:
PYTHONPATH=python python examples/surface_dispersion.py
PYTHONPATH=python python examples/lines_orbit.py
PYTHONPATH=python python examples/mesh_scene.py
surface_dispersion.pyshows a log-frequency surface with orbit controls.lines_orbit.pyshows line strips, axis references, and a shared orbit camera.mesh_scene.pyshows the future lower-level scene shape with mesh, path, and light nodes.
The larger app-authored demos mirror the Rust showcase programs:
# Dump the native app IR without requiring a GPUI host.
GPUI_TOOLKIT_DUMP_IR=1 PYTHONPATH=python python examples/spinorama_demo.py
GPUI_TOOLKIT_DUMP_IR=1 PYTHONPATH=python python examples/surface3d_demo.py
GPUI_TOOLKIT_DUMP_IR=1 PYTHONPATH=python python examples/chart_gallery.py
# Without a host-related environment variable, each script prints JSON too.
PYTHONPATH=python python examples/spinorama_demo.py > /tmp/spinorama-python.json
spinorama_demo.pycontains CEA2034, horizontal SPL, vertical SPL, contour, and retained 3D surface sections using deterministic local data.surface3d_demo.pycontains the sinc, spinorama-style, and saddle surface modes from the Rustsurface3d_demo.chart_gallery.pycovers scatter, line, area, heatmap, contour, isoline, bar, pie, donut, box-plot, and treemap declarations.
Replace the local data-builder functions with measurement or application data when adapting a demo; the chart and Scene3D declarations remain unchanged.
Python Package
The Python declarations are packaged as gpui-toolkit with the import package
gpui_toolkit. Wheels contain a private PyO3 abi3-py310 extension for pure
native computations, while Rust/GPUI remains the rendering host. The base
wheel has no Python runtime dependencies.
python -m pip install gpui-toolkit
python -c "from gpui_toolkit import native; print(native.AVAILABLE)"
Build a platform wheel with maturin (rather than invoking Cargo's cdylib
directly):
maturin build --manifest-path Cargo.toml --release
The installed extension is gpui_toolkit._native; public code should import
gpui_toolkit.native or the corresponding gpui_toolkit.d3rs functions.
Native d3rs array statistics, search, tick generation, numeric/array and
RGB/HSL/Lab/HCL/Cubehelix interpolation, color operations, and linear_scale
execute the corresponding gpui-d3rs implementation. Substantial array work
releases the GIL.
Command request objects remain available for deliberately host-owned execution.
The package version matches the Rust crate version. Update both
pyproject.toml and Cargo.toml together when releasing a new Python-facing
runtime.
Showcase Application
Run the Python-authored native GPUI showcase with retained 3D scenes and
embedded gpui-px charts:
cargo run -p gpui-python-runtime --features showcase --bin gpui-python-showcase -- crates/gpui-toolkit/gpui-python-runtime/python/showcase.py
PYTHONPATH=crates/gpui-toolkit/gpui-python-runtime/python ./venv/bin/python crates/gpui-toolkit/gpui-python-runtime/python/showcase.py
The complete gpui-d3rs gallery can use the same generic host with no
d3rs-showcase-specific Rust route:
cargo run -p gpui-python-runtime --features showcase --bin gpui-python-showcase -- crates/gpui-python-runtime/python/d3_showcase.py
The abi3 wheel publishes nullable Boolean, integer, floating-point, and UTF-8
Dataset columns as Arrow IPC without Python dependencies. Install the
optional Arrow adapter when nested or temporal columns need PyArrow's richer
conversion support:
python -m pip install 'gpui-toolkit[arrow]'
Declare every live Dataset and ArrayData object on the application:
app = App(sections=(...), resources=(events, spectrum_grid))
The base App.on_session_ready publishes initial binary generations and
subscribes to later commits. Overrides must call
super().on_session_ready(context) before issuing application-specific
commands. Resource values never enter the JSON application snapshot.
The base wheel remains dependency-free. Source-only use without either the native extension or PyArrow can still dump declarations, while starting a live dataset app raises a typed transport error instead of displaying an unpopulated chart.
The installed host negotiates resource_mmap_frames and creates a private
0700 directory with a high-entropy session token. Python publishes each
complete dataset or ArrayData generation as a 0600 file; the host validates
the token, local filename, size, permissions, and checksum, maps it read-only,
and unlinks it immediately on Unix. The retained mapping is consumed directly
by Arrow/table/chart and dense-array readers. Bounded binary stdout frames are
used only when mmap transport is unavailable. Dataset and mesh frames carry
payload checksums. Per-frame acknowledgements drive shared Python in-flight
byte accounting, typed rejection reporting, backpressure, and deterministic
fallback cleanup.
Native consumers acquire generation-scoped leases. Publishing a new generation
keeps an older mapped generation alive only while a retained consumer still
owns it; explicit drops cannot invalidate active owners, and the final release
reclaims both the mapping and its byte-budget charge.
Resource-backed scatter, line, area, boxplot, bar, pie, and
donut declarations execute bounded LOD sampling from Dataset/DatasetView or
numeric ArrayData frames. heatmap, contour, and isoline consume only a
two-dimensional ArrayData grid ([height, width]) and never flatten it into
JSON. One projection, one stable sort, and one range(...) execute in the
host. Tables, aggregate pipelines, resource-backed charts, and static export
execute the typed DatasetView.filter AST, including comparisons, boolean
composition, membership, and null checks. Projection is enforced by Python,
Rust IR validation, and each consumer. Tables sort before extracting
their visible window. Tables, resource-backed charts, and static chart export
execute one group_by(...).aggregate(...) stage over Arrow batches, then sort
and consume only the bounded aggregate window. Supported reducers are count,
sum, mean, min, max, first, and last. Scatter and line charts sort on their
bound x or y role.
Chart sort-plus-range remains explicitly rejected until it can preserve full
pipeline ordering. Tables retain primary-key selection, scatter/line charts
emit keyed point selections and viewport changes, treemaps emit keyed
selection, and surfaces emit retained camera viewport changes.
Scene3D surfaces, line-strip points, mesh vertices, triangle indices, and
scalar fields accept ArrayData. Their declarations contain only resource
descriptors; the host resolves the exact generation and validates shape and
dtype before creating native geometry or GPU state.
The showcase app, sections, UI kit demos, chart data, and scene3d specs live
in Python. Rust loads the JSON UI IR, then owns GPUI, retained 3D renderer
state, chart widgets, and theme integration.
Scene2D surfaces and game input
gpui_toolkit.scene2d declares small native drawing surfaces with stable
object IDs. A Scene2D has a logical view box, ordered rect/circle/line/path/
text nodes, small transform groups, solid or linear-gradient brushes, local
clips, bounded primitive shadows, an optional background and GridSpec,
semantic labels, and input settings. Transitions can interpolate transforms,
opacity, selected colors, and path reveal, then emit a requested completion ID
once. The
native host contain-fits that view box in the parent layout bounds. Python can
publish a full scene2d_replace or a consecutive-revision scene2d_patch;
SessionContext.scene2d_patch(...) can include related HUD operations in the
same revisioned context.patch message.
The wire operation nests its delta under patch:
{"op":"scene2d_patch","id":"board","patch":{"base_revision":1,"revision":2,"upsert":[],"remove":[]}}.
Pointer, focused-key, lifecycle, and elapsed-tick messages specialize to
Scene2DEvent and Scene2DTick. Scene2DInputConfig.keyboard=True scopes key
delivery to the focused drawing surface; game handlers still choose which keys
they use. Setting App.serial_reducer=True runs actions, surface input, ticks,
effect results, command results, and profiler callbacks in one ordered lane.
The lane has bounded input admission, reserved lifecycle capacity, and clears
held input after overflow. Reducers should publish model-derived UI and scene
changes together before returning. Accessibility activation of a semantic
button or grid cell uses the same typed scene event path.
Handler exceptions report action_failed with the event, node, action, and
exception type/message. The exception description is limited to 1,024
characters. Python stderr receives the full traceback for diagnosis.
App.tick_interval can seed an elapsed-time schedule. A reducer can adjust or
cancel it later with SessionContext.set_tick_interval(seconds_or_none). The
host owns its monotonic timer, pauses delivery for inactive sections and
inactive windows, and resets elapsed time when the app or section resumes.
Focus loss clears held keys and contacts even when the active section stays the
same. Reducers should use elapsed time with a small catch-up bound and request
ticks only while work is active. Native transitions animate target properties,
so Python does not need to send patches every frame.
The games_demo.py example uses geometric Scene2D boards for Zip, Queens,
Sudoku, Tetris, Chess, and Othello (one game module per file under
games_demo/). Sudoku keeps a large keypad and selected-cell preview next
to its board; the other boards expose semantic grid cells without drawing a
widget button for each cell. Game cue commands go through the optional
GameCueAdapter boundary. It accepts an already initialized CueBackend,
uses a bounded nonblocking queue, and deduplicates recent command IDs. With no
backend it remains silent. The current sotf-daw checkout has no Python cue
binding, so the demo does not claim audio playback is connected.
The drawing surface and its input contract use native GPUI elements. The host
owns the OS window lifecycle and Python reducer transport. This checkout's
Python launcher runs CPython in a desktop child process, so games_demo.py is
not bundled into the mobile showcase binaries. Mobile apps use the native Rust
GPUI surface path in the existing iOS and Android backends; this delivery does
not package a mobile Python interpreter.
Native input development API
Enable the local file API when launching a host built from this checkout:
GPUI_TOOLKIT_DEV_API=/tmp/gpui-dev \
python3 crates/gpui-python-runtime/python/examples/games_demo.py
python3 scripts/python_dev_api.py /tmp/gpui-dev '{"command":"select","section":"queens"}'
python3 scripts/python_dev_api.py /tmp/gpui-dev '{"command":"click","surface":"queens-board","x":40,"y":40}'
python3 scripts/python_dev_api.py /tmp/gpui-dev '{"command":"status"}'
The API is disabled by default. Each host needs its own directory; clients
submit one request at a time. scripts/python_dev_api.py handles atomic files
and response IDs. A successful input response means the input was sent;
inspect subsequent status responses to check Python results.
Commands:
status: current section, committed application revision and IR, surface errors, captured Python stderr, and window bounds for surfaces and buttons.select: select an applicationsection.window_click: send mouse down/up at window coordinatesx,ythrough GPUI's normal event dispatch, layout hit-testing, and Python callbacks.click: send mouse down/up to asurfaceat logical scene coordinatesx,y. The retained native router computes hit IDs and grid cells.pointer: route one surface sample withphase(down,move,up,cancel),device(mouse,touch,pen),contact_id,x, andy.key: route a surfacekeywithphase(down,up).
Run the live regression with a built host:
python3 scripts/python_games_smoke.py target/release/gpui-python-host
It opens a separate native window with temporary presentation state, clicks
Queens, Zip, Sudoku, Chess, Othello, and Tetris through GPUI, checks scene
patches and live ticks, exercises two touch contacts, changes the palette,
and closes its host.
The test fails on native session errors or Python stderr. Handler errors
include the event, node, action, exception type, and exception message;
the full traceback is captured in stderr and available through status.
Platform Notes
Scene2D primitives paint through native GPUI elements and follow each
platform's GPUI renderer (Metal on Apple platforms and the existing wgpu
backend on Android). Scene3D and the other GPU-backed visualizations use
wgpu via gpui-d3rs:
- macOS/iOS: Metal,
- Linux: Vulkan where available,
- Windows: DirectX 12 or Vulkan depending adapter support,
- Android: Vulkan through the existing GPUI Android backend.
The Python API is intended to stay the same across platforms; only GPUI backend initialization should differ.
Metadata
Release files for gpui-toolkit 0.10.46
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| gpui_toolkit-0.10.46-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| gpui_toolkit-0.10.46-py3-none-manylinux_2_39_x86_64.whl | Python 3 | none | Linux glibc 2.39+ x86-64 | Details |
| gpui_toolkit-0.10.46-py3-none-macosx_15_0_x86_64.whl | Python 3 | none | macOS 15.0+ x86-64 | Details |
| gpui_toolkit-0.10.46-py3-none-macosx_15_0_arm64.whl | Python 3 | none | macOS 15.0+ ARM64 | Details |
| gpui_toolkit-0.10.46-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 89.2 MB
Release files / gpui_toolkit-0.10.46-py3-none-win_amd64.whl
| Download URL | gpui_toolkit-0.10.46-py3-none-win_amd64.whl |
|---|---|
| Size | 30.8 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
64bac8bdc4ce6b6a62922744ca034513a37da68887a3576a18241b484052b58c
|
|
BLAKE2b-256 checksum How to use checksums |
f5d4fe88ef1e91e64b4195c46dea08b6b85613b7366cedee54ea9fef2cec22aa
|
| 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 Oct 21, 2026.
Transparency logRelease files / gpui_toolkit-0.10.46-py3-none-manylinux_2_39_x86_64.whl
| Download URL | gpui_toolkit-0.10.46-py3-none-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 24.4 MB |
| Tags | Linux glibc 2.39+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
f2d1bea0a8962173c0afb48407f443efadce4593085eee705e909bfe3d87db34
|
|
BLAKE2b-256 checksum How to use checksums |
7407a2da3fe6959362e23d64235ad3d1e924ff86751e88f067968487cc3411b9
|
| 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 Oct 21, 2026.
Transparency logRelease files / gpui_toolkit-0.10.46-py3-none-macosx_15_0_x86_64.whl
| Download URL | gpui_toolkit-0.10.46-py3-none-macosx_15_0_x86_64.whl |
|---|---|
| Size | 17.3 MB |
| Tags | Python 3 macOS 15.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
ad4bccc85e063eba0c3a08f54c6e89ed1652fdb352527b66cf59dd264c6cf027
|
|
BLAKE2b-256 checksum How to use checksums |
99e8fc366669faa8ddcf8af84ccbc532754dc87f0076145b0106e7a579dbf271
|
| 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 Oct 21, 2026.
Transparency logRelease files / gpui_toolkit-0.10.46-py3-none-macosx_15_0_arm64.whl
| Download URL | gpui_toolkit-0.10.46-py3-none-macosx_15_0_arm64.whl |
|---|---|
| Size | 16.4 MB |
| Tags | Python 3 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ae2939eabf3dc05547dbc9e489c109a10d75e2e9d7dda2f56f2687bfe3d3eb13
|
|
BLAKE2b-256 checksum How to use checksums |
15c584a37d1ada5e68e786aa76505500d6209998dce351739e2d30995ab774d9
|
| 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 Oct 21, 2026.
Transparency logRelease files / gpui_toolkit-0.10.46-py3-none-any.whl
| Download URL | gpui_toolkit-0.10.46-py3-none-any.whl |
|---|---|
| Size | 253.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b5786611703d09ccfbedffcaa473facd6d2b4211bcc20fdef18315ce487a2fc
|
|
BLAKE2b-256 checksum How to use checksums |
c031f4162c33f72916772d868720008015e1a23a5a152503e41da2cd7011c5bb
|
| 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 Oct 21, 2026.
Transparency logSecurity for gpui-toolkit 0.10.46
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.
Attestation for gpui_toolkit-0.10.46-py3-none-win_amd64.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 Oct 21, 2026.
Transparency logA 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.