Expand description
The Python runtimes a firmware can speak, and the staging text pasted into their REPLs.
A board configured with a Python runtime boots a stock interpreter instead of the project’s own application. The runner never imports or executes the guest’s Python itself: it waits for the REPL prompt, sends the raw-REPL control bytes and pastes a program, so everything here is pure bytes and strings. Keeping it separate from the run loop is what makes the handshake testable without booting a chip.
MicroPython and CircuitPython share the friendly-REPL prompt and the raw
paste framing. They differ in the file the interpreter runs on boot —
CircuitPython looks for code.py, MicroPython for main.py — and in
whether a program may already be running when the paste arrives.
Enums§
- Python
Runtime - Which interpreter a board’s console speaks.
Constants§
- REPL_
PROMPT - The friendly-REPL prompt both runtimes print. It is the only sign the interpreter is ready; matching a banner would tie the runner to one build’s wording.
Functions§
- detect
- Which interpreter a board’s console speaks, from the configured runtime and a firmware hint: its file name or a captured banner.
- detect_
bytes detectfor a firmware image or a console banner the caller already holds as bytes. The scan is case-insensitive and does not require the hint to be UTF-8.- entry_
candidates PythonRuntime::entry_candidatesas a free function.- entry_
name PythonRuntime::entry_nameas a free function, so a call site that already holds the runtime can readentry_name(runtime).- interrupt_
sequence PythonRuntime::interrupt_sequenceas a free function.- raw_
paste_ begin PythonRuntime::raw_paste_beginas a free function.- raw_
paste_ end PythonRuntime::raw_paste_endas a free function.- stage_
program - The Python a multi-file project pastes. It writes every staged file through
open(..., 'wb'), creating the directories the path needs, then runs the entry file in the REPL’s own globals so__name__stays__main__.