Installation
Node
@struktoai/mirage-browser and @struktoai/mirage-core
instead: Pyodide loads from its CDN or home, not the pyodide package. The
page must be cross-origin isolated or registered with Mirage’s service worker; see
worker and browser setup.
Usage
- TypeScript
- YAML
Packages
Pyodide’s packages, such as numpy, load when a program imports them. The first import downloads the package from the Pyodide CDN; Node keeps it beside the installedpyodide package for later runs.
- TypeScript
- YAML
micropip.install
fails. Put its pure-Python wheel on a mount and list it in sys_path.
Memory
max_memory caps the memory one run may grow to:
MemoryError, and the next run starts fresh. Node stops the run when it
passes the cap; browsers check the cap when the run ends.
Without its own max_memory, a run may grow by what its workspace’s
max_memory has left,
96 MB by default, past what the interpreter and its packages take to start.
Python compatibility
Examples assume a writable/data mount. Mount modes and permissions still apply.
open()
Modes and modifiers are listed separately; for example, rb combines r
and b. The file is read when it is opened.
Example: append to a workspace file
Example: append to a workspace file
Limitations
Limitations
File objects
Example: write, read and truncate a file
Example: write, read and truncate a file
Limitations
Limitations
os
File operations
Directory operations
Metadata and links
Environment and working directory
Example: list a workspace directory
Example: list a workspace directory
Limitations
Limitations
os.path
Example: check a workspace path
Example: check a workspace path
pathlib
Example: create and inspect a workspace file
Example: create and inspect a workspace file
sys
Example: read arguments and piped input
Example: read arguments and piped input
time and datetime
The clocks start at the workspace’s system time
when it sets one, and files the program writes are stamped from the same
clock. time.monotonic() and time.perf_counter() measure elapsed time.
Example: print today's date
Example: print today's date
Limitations
Limitations
json
Example: write and read workspace JSON
Example: write and read workspace JSON
glob
Example: find workspace text files
Example: find workspace text files
shutil
shutil.which(): Resolves executable names through Mirage’s command lookup.
Example: move a workspace file
Example: move a workspace file
Limitations
Limitations
subprocess
Example: run a Mirage command
Example: run a Mirage command
Limitations
Limitations
Processes and signals
Limitations
Limitations
socket
Network connections are unavailable in this runtime.
Limitations
Limitations
mmap
Unavailable in this runtime.
Limitations
Limitations