Repository navigation
Ariadne: arix and ariglx, ari and arigl with an embedded Python - #1000
Merged
Merged
Conversation
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
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andAriApp): the base isfeat/pycvc-gl-ariadne-host, so this diff is only P1.What it adds
arixandariglx:ariandariglwith an embedded CPython. They take the same commands and flags, and add:python:block. It runs at load, beforerequires:is checked. Its@exportfunctions andexport:entries become the document's host functions (pycvc.host_function): arguments in, a value back, async withasync: true. A Python exception is aPythonErrorthe document can catch, and one at load fails the load with the document's traceback.ariglx run app.py,snapshot,check, andarixtoo.pycvc_gl.ariadne.Host()adopts the host (new mode"embedded", the default inside a scripting host), andhost.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 plainpython.<host> python [args]: the embedded interpreter as a plainpython3.--python-path DIR: a new general flag. Stock hosts refuse it.pythonandpython.<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 apython:block is ignored with a warning.src/ariadne_python). One interpreter per process, from the install prefix'spython312(else the Python built against).PYTHONHOMEandPYTHONPATHwork as forpython3. The GIL is parked between crossings. The_arihostbuiltin lends the host's app, document runtime and (ariglx) window objects for the life of anAttachment. The engine is constructed before the app and runtime, and finalized after them.AppRuntime::add_load_hook: after the parse, beforerequires:;AppRuntime::add_frame_hook: at the end of eachdrain(), where an embeddedHost'son_frame/watch/onrun;AppRuntime::prefix();set_script_engine/capability_hintinrequires.h.pycvc.ari_app_attach(app, runtime): a non-owningAriApp;pycvc_gl.{ari_runtime,scene_renderer,camera_controller,imgui_overlay}_from_capsule;pycvc_gl.ariadne.current_host()andexport.Packages (second commit)
cvcpkg/recipes/arixandariglx, Linux only (wherepycvc-cp312/pycvc-gl-cp312are published).src/ariorsrc/ariglstandalone with-DARI_WITH_PYTHON/-DARIGL_WITH_PYTHONagainst the installed SDKs.python3.12is named outright, so a systempython3is never embedded.python312,numpy-cp312,pycvc-cp312(andpycvc-gl-cp312for ariglx) into the same prefix. The installed host finds that Python beside it with noPYTHONHOME.publish-cvcpkg.ymlbuilds both in the cp312 Linux job, smoke-tests each, then packs and publishes it with the release.arix pythonand thepython:block test document through that job's pycvc.src/ari/src/ariglalone against an SDK installed from this tree, installs onlybin/arix.exe/bin/ariglx.exe. The binary has no builder path, and put in a prefix besidepython312it found that Python and passed thepython:block tests.Tests
New:
arix_python_block(arix test: plain, renamed, module,export:/as:and async exports, a caughtPythonError, the tokens);arix_python_programandariglx_python_program(a program gives its document a function, runs the host's frames, and checks itson_framehook ran);arix_python_error,arix_python_interpreter,ari_python_needs_arix,ariglx_python_check;ScriptLanguageTokensHoldOnlyWithItsEngine,ALoadHookRunsBeforeRequiresIsChecked,AFrameHookRunsAfterEachDrain.pycvc-linuxnow buildsari arix ariglxand 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
python3123.12.10 + numpy 2.4.6 + swig 4.4.1:ariadne_requires_test20,ariadne_loader_test214 (+2 skipped),ariadne_host_test55,ariadne_runtime_test248,ari_test_command_test8;pycvc_ariadne,pycvc_gl_ariadne_host,pycvc_gl_ariadne_gil,pycvc_ariand the smoke tests pass with theHostchanges;ariglx runof a Python program in a real window: 60 frames, closed from itson_framehook, exit 0.Not done (later P1 / phases)
pycvc-cp312/pycvc-gl-cp312there (N1). On Windows the cvcpkgpython312keepspython312.dllbesidepython.exe, not inbin/, so those recipes will have to place it.load:ed module'spython:block is not run, so--python-allow(the native trust rule for non-local documents) has nothing to gate yet.ariglx --terminalyet.Host.load()from inside a frame raises.run -mbecame<host> python -m ...(e.g.ariglx python -m grl_snam.ariadne live ...).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.ariglx: torch etc. aren't in the test prefix.ariglx-web) andarisrvxare later phases.