Skip to content

Ariadne: arix and ariglx, ari and arigl with an embedded Python - #1000

Merged
transfix merged 4 commits into
feat/pycvc-gl-ariadne-hostfrom
feat/ariadne-python-engine
Nov 3, 2026
Merged

transfix merged 4 commits into
feat/pycvc-gl-ariadne-hostfrom
feat/ariadne-python-engine

Conversation

@transfix

@transfix transfix commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

The first part of the scripting hosts roadmap (ARIADNE_SCRIPTING_HOSTS.md, P1, from #992), native. Stacked on #985 (it uses #985's Host, host functions with values and AriApp): the base is feat/pycvc-gl-ariadne-host, so this diff is only P1.

What it adds

  • arix and ariglx: ari and arigl with an embedded CPython. They take the same commands and flags, and add:
    • A document's python: block. It runs at load, before requires: is checked. Its @export functions and export: entries become the document's host functions (pycvc.host_function): arguments in, a value back, async with async: true. A Python exception is a PythonError the document can catch, and one at load fails the load with the document's traceback.
    • A Python program in place of the document: ariglx run app.py, snapshot, check, and arix too. pycvc_gl.ariadne.Host() adopts the host (new mode "embedded", the default inside a scripting host), and host.run() runs the host's own loop. A program that loads a document and returns has the host run it. The same program runs under plain python.
    • <host> python [args]: the embedded interpreter as a plain python3.
    • --python-path DIR: a new general flag. Stock hosts refuse it.
  • Tokens. python and python.<module> are capability tokens. On a stock host a document that requires them fails with "a document's python runs in the scripting hosts, arix or ariglx", and a python: block is ignored with a warning.
  • The engine (src/ariadne_python). One interpreter per process, from the install prefix's python312 (else the Python built against). PYTHONHOME and PYTHONPATH work as for python3. The GIL is parked between crossings. The _arihost builtin lends the host's app, document runtime and (ariglx) window objects for the life of an Attachment. The engine is constructed before the app and runtime, and finalized after them.
  • Core seams:
    • AppRuntime::add_load_hook: after the parse, before requires:;
    • AppRuntime::add_frame_hook: at the end of each drain(), where an embedded Host's on_frame / watch / on run;
    • AppRuntime::prefix();
    • set_script_engine / capability_hint in requires.h.
  • Bindings:
    • pycvc.ari_app_attach(app, runtime): a non-owning AriApp;
    • pycvc_gl.{ari_runtime,scene_renderer,camera_controller,imgui_overlay}_from_capsule;
    • pycvc_gl.ariadne.current_host() and export.
  • Docs. ARIADNE.md §9.6 covers the hosts, and §11 lists what is not wired yet.

Packages (second commit)

  • Recipes: cvcpkg/recipes/arix and ariglx, Linux only (where pycvc-cp312 / pycvc-gl-cp312 are published).
    • Each builds src/ari or src/arigl standalone with -DARI_WITH_PYTHON / -DARIGL_WITH_PYTHON against the installed SDKs.
    • The deps prefix's python3.12 is named outright, so a system python3 is never embedded.
    • Each installs only its own binary.
  • Runtime deps bring python312, numpy-cp312, pycvc-cp312 (and pycvc-gl-cp312 for ariglx) into the same prefix. The installed host finds that Python beside it with no PYTHONHOME.
  • No builder path ships: a recipe build no longer compiles in the build's Python home, which is now in-tree only.
  • Publishing: publish-cvcpkg.yml builds both in the cp312 Linux job, smoke-tests each, then packs and publishes it with the release.
    • arix runs arix python and the python: block test document through that job's pycvc.
    • ariglx, last, loads that document and renders the Python program's document under Xvfb.
  • Local check (Windows): the recipes' standalone path, src/ari / src/arigl alone against an SDK installed from this tree, installs only bin/arix.exe / bin/ariglx.exe. The binary has no builder path, and put in a prefix beside python312 it found that Python and passed the python: block tests.
  • Linux check: dry run 41598099932 on this branch (no publish).

Tests

New:

  • arix_python_block (arix test: plain, renamed, module, export:/as: and async exports, a caught PythonError, the tokens);
  • arix_python_program and ariglx_python_program (a program gives its document a function, runs the host's frames, and checks its on_frame hook ran);
  • arix_python_error, arix_python_interpreter, ari_python_needs_arix, ariglx_python_check;
  • AriadneRequires ScriptLanguageTokensHoldOnlyWithItsEngine, ALoadHookRunsBeforeRequiresIsChecked, AFrameHookRunsAfterEachDrain.

pycvc-linux now builds ari arix ariglx and runs ^(arix_|ariglx_|ari_python_) under its Xvfb. The step fails if fewer than 7 tests are registered.

Locally, Windows, MSVC 14.44, the cvcpkg python312 3.12.10 + numpy 2.4.6 + swig 4.4.1:

  • the 7 new ctests pass;
  • the ari / arigl ctests pass;
  • ariadne_requires_test 20, ariadne_loader_test 214 (+2 skipped), ariadne_host_test 55, ariadne_runtime_test 248, ari_test_command_test 8;
  • pycvc_gl.ariadne: a Python host for Ariadne documents #985's pycvc_ariadne, pycvc_gl_ariadne_host, pycvc_gl_ariadne_gil, pycvc_ari and the smoke tests pass with the Host changes;
  • ariglx run of a Python program in a real window: 60 frames, closed from its on_frame hook, exit 0.

Not done (later P1 / phases)

  • Windows and macOS packages wait on pycvc-cp312 / pycvc-gl-cp312 there (N1). On Windows the cvcpkg python312 keeps python312.dll beside python.exe, not in bin/, so those recipes will have to place it.
  • A load:ed module's python: block is not run, so --python-allow (the native trust rule for non-local documents) has nothing to gate yet.
  • A Python program can't run under ariglx --terminal yet.
  • An embedded Host.load() from inside a frame raises.
  • run -m became <host> python -m ... (e.g. ariglx python -m grl_snam.ariadne live ...).
  • The roadmap said an explicit Host(mode=...) inside a host would raise. It opens a Host of its own instead, which is more useful. The roadmap doc gets that and the rest of these notes once this branch is on master.
  • GRL-SNAM's ports weren't run under ariglx: torch etc. aren't in the test prefix.
  • Browser (ariglx-web) and arisrvx are later phases.

The first part of the scripting hosts (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md, P1), native:

- src/ariadne_python: the engine. One CPython per process, booted from the install prefix's
  python312 (else the Python built against), the GIL parked between crossings. The _arihost
  builtin lends Python the host's app, document runtime and (ariglx) window objects.
- A document's python: block runs at load, before requires: is checked; its @export functions
  (and export: entries) become host functions through pycvc.host_function. The python and
  python.<module> capability tokens hold there; a stock host names the scripting hosts instead.
- A Python program in place of the document (arix|ariglx run|snapshot|check app.py):
  pycvc_gl.ariadne.Host() adopts the host (mode "embedded"), and host.run() runs the host's own
  loop. <host> python [args] is the embedded interpreter as a plain python3. --python-path DIR.
- AppRuntime::add_load_hook and add_frame_hook; pycvc.ari_app_attach; pycvc_gl's
  *_from_capsule proxies over a host's window objects.
- ctest: arix_python_* (block, program, error, interpreter), ari_python_needs_arix,
  ariglx_python_check / _program; three AriadneRequires cases. pycvc-linux builds and runs them.
The scripting hosts as cvcpkg packages of their own, so ari and arigl stay Python-free. Each
recipe builds src/ari or src/arigl standalone with -DARI_WITH_PYTHON / -DARIGL_WITH_PYTHON
against the installed SDKs and the deps prefix's python312 (named outright, not a system
python3), and installs only its own binary. Runtime deps bring python312, numpy-cp312,
pycvc-cp312 (and for ariglx pycvc-gl-cp312) into the same prefix, where the installed host
finds its Python beside it. Linux only, where pycvc-cp312 and pycvc-gl-cp312 are published.

A recipe build no longer compiles in the build's Python home (CVC_ARIADNE_PYTHON_HOME is
in-tree only), so no builder path ships.

publish-cvcpkg.yml builds, smoke-tests, packs and publishes both in the cp312 job: arix runs
`arix python` and the python: block test document through that job's pycvc; ariglx, last,
loads it and renders the Python program's document under Xvfb.
…that packs them

The dry run (41598099932) built both and both passed their smoke tests on Linux (arix: its
interpreter and python_block.ari 5/5; ariglx: the python: block in a window and app.py rendered),
then cvcpkg pack died with "No module named 'cvcpkg'": the exported PYTHONHOME pointed cvcpkg's
own Python at $PY's stdlib. The hosts now get it through env, one command at a time.
…dne-python-engine

arigl's run_window: master's snapshot that ends at the frame a document
quits on, and the browser loop paced by the next animation frame
(arigl_wait_frame, CVC_ARIGL_YIELD=timeout), go into the after_load lambda
that ariglx's Python program runs; set_log_verbosity sits beside
lend_python.
@transfix
transfix merged commit ce58174 into feat/pycvc-gl-ariadne-host Nov 3, 2026
5 of 6 checks passed
@transfix
transfix deleted the feat/ariadne-python-engine branch November 3, 2026 20:39
transfix added a commit that referenced this pull request Nov 5, 2026
* pycvc_gl.ariadne: a Python host for Ariadne documents

Host functions with arguments and a value (AppRuntime::register_function / register_async_function; pycvc.host_function from Python), a GL-free host (pycvc.AriApp), and pycvc_gl.ariadne.Host over AriRuntime or AriApp: data in (values, trees, tables, series, pictures, streams), data out (get, watch, frames), and the document's calls into Python.

The GIL: AriRuntime's frame/render/step/run/load/wait_idle and its destructor, AriApp's, and cvc::app's destructor release it, so an async Python function finishes while frames run, under run(), and at teardown (del app with a call in flight deadlocked). A frame entered from inside one raises.

Examples (hello, data_feed, form, nav) in examples/ariadne/python, tests pycvc_ariadne, pycvc_gl_ariadne_host and pycvc_gl_ariadne_gil, and docs/ARIADNE.md 9.3 Writing a Python host.

* Python host: nav example on Austin with Humvees and a plant pick; host-function C++ tests

examples/ariadne/python/nav.py drives Humvees on a sim_world through Austin when its bundle is installed (a block city otherwise): true-scale models, routes planned for their turning radius, Jolt or kinematic plant, chase or overview camera, map picture, terrain_lab's soft afternoon look.

pycvc.nav_world_rasterize (cvc::nav::rasterize, no VTK), nav_plant(ground=field), pycvc_gl.scenes.find_scene / find_vehicle_model, pycvc_gl.vehicle.VehicleModel / seat_transform / body_transform. AriadneHostVerbs tests for register_function and register_async_function.

* nav.py: the grade in the navigator and off the routes

The terrain's height at each grid sample (nav_world_rasterize) goes to the navigator with the Humvee's terrain_config_of (nav_sim_world_set_terrain), and the routes keep off the slopes nav_terrain_build marks infeasible. On Austin's relief (--relief) that halves the Jolt rollovers (8 -> 4 of 16 in 96 s); the rest are cornering on 10-25 degree side slopes at 5-9 m/s, which the climb limit does not cover, so flat-ground physics stays the default.

* Python host docs: the scene and pictures belong to the frame's thread

* Python host examples: data_feed and nav declare what they need (requires:)

AriadneComponents.ShippedExamplesDeclareWhatTheyNeed failed on every CI
platform: python/data_feed.ari and python/nav.ari had no requires: block,
and nav.ari has a scene: without requiring gl.scene.

data_feed.ari requires quit, with stream_view and raster.bitmap optional
(a headless run shows text). nav.ari requires gl.scene and quit, so, like
every shipped document with a scene, a host without a scene refuses it:
nav.py --headless now says so instead of running, and its headless
branches are gone. The host test's nav runs (kinematic and Jolt) move to
the offscreen section, which CI runs on llvmpipe under Xvfb, and the
headless section checks the refusal.

* ariadne_host_test: the async-function test gives its action room (macOS CI)

AnAsyncFunctionTakesArgumentsAndPostsToItsChannel failed on package-macos / libcvc-release: the
call's wait is charged to the action (ariadne.limits.action_max_time, 0.1 s by default), and on the
loaded macOS runner starting the kernel and its 20 ms took longer, so the program was stopped
(time_limit_exceeded) before it set got or posted to the channel. Reproduced here with the cap set
to 0.5 ms (the same failure, and run_program's done says time_limit_exceeded). The test is about the
arguments and the channel, so it sets the cap a host gives (30 s) and checks the program finished.

* Ariadne: arix and ariglx, ari and arigl with an embedded Python (#1000)

* Ariadne: arix and ariglx, ari and arigl with an embedded Python

The first part of the scripting hosts (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md, P1), native:

- src/ariadne_python: the engine. One CPython per process, booted from the install prefix's
  python312 (else the Python built against), the GIL parked between crossings. The _arihost
  builtin lends Python the host's app, document runtime and (ariglx) window objects.
- A document's python: block runs at load, before requires: is checked; its @export functions
  (and export: entries) become host functions through pycvc.host_function. The python and
  python.<module> capability tokens hold there; a stock host names the scripting hosts instead.
- A Python program in place of the document (arix|ariglx run|snapshot|check app.py):
  pycvc_gl.ariadne.Host() adopts the host (mode "embedded"), and host.run() runs the host's own
  loop. <host> python [args] is the embedded interpreter as a plain python3. --python-path DIR.
- AppRuntime::add_load_hook and add_frame_hook; pycvc.ari_app_attach; pycvc_gl's
  *_from_capsule proxies over a host's window objects.
- ctest: arix_python_* (block, program, error, interpreter), ari_python_needs_arix,
  ariglx_python_check / _program; three AriadneRequires cases. pycvc-linux builds and runs them.

* cvcpkg: arix and ariglx recipes, published from the cp312 Linux job

The scripting hosts as cvcpkg packages of their own, so ari and arigl stay Python-free. Each
recipe builds src/ari or src/arigl standalone with -DARI_WITH_PYTHON / -DARIGL_WITH_PYTHON
against the installed SDKs and the deps prefix's python312 (named outright, not a system
python3), and installs only its own binary. Runtime deps bring python312, numpy-cp312,
pycvc-cp312 (and for ariglx pycvc-gl-cp312) into the same prefix, where the installed host
finds its Python beside it. Linux only, where pycvc-cp312 and pycvc-gl-cp312 are published.

A recipe build no longer compiles in the build's Python home (CVC_ARIADNE_PYTHON_HOME is
in-tree only), so no builder path ships.

publish-cvcpkg.yml builds, smoke-tests, packs and publishes both in the cp312 job: arix runs
`arix python` and the python: block test document through that job's pycvc; ariglx, last,
loads it and renders the Python program's document under Xvfb.

* publish-cvcpkg: PYTHONHOME for arix and ariglx alone, not the cvcpkg that packs them

The dry run (41598099932) built both and both passed their smoke tests on Linux (arix: its
interpreter and python_block.ari 5/5; ariglx: the python: block in a window and app.py rendered),
then cvcpkg pack died with "No module named 'cvcpkg'": the exported PYTHONHOME pointed cvcpkg's
own Python at $PY's stdlib. The hosts now get it through env, one command at a time.

* arix, ariglx recipes: upstream_version 3.7.10, with master's bump (#1022)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant