ws.execute('python3 ...') can open(), os.listdir(), pathlib.Path() etc. against any registered Mirage mount. The shim routes those calls through Mirage’s mount layer (RAM, S3, Linear, GDocs, Slack, anything you’ve registered).
What works
- Read a file
- Write a file
- List a directory
- pathlib & glob
- Native libs
- Cross-mount
What doesn’t work
How it works (one paragraph)
Pyodide’s in-memory FS (MEMFS) is the sync facade. AtaddMount, Mirage walks the prefix and copies files into MEMFS. Python reads hit MEMFS directly, fast, no network. On a miss (path not yet in MEMFS but the prefix is registered), the shim catches the error, calls back through the bridge via JSPI to fetch it, populates MEMFS, and retries. Writes are intercepted on close() and flushed back through Mirage’s write op.
Quick start (TypeScript)
examples/typescript/pyodide/vfs.ts.
Python packages (PIL, numpy, pandas, …)
Pyodide ships CPython, but third-party packages aren’t loaded until you import them. Mirage scans the code you run forimport statements and auto-fetches matching packages on demand, so from PIL import Image, import numpy as np, import pandas as pd all just work the first time. Subsequent calls hit Pyodide’s package cache.
If you need to opt out (e.g., to keep workspace startup lean):
Resource compatibility
Runtime requirements
The shim uses JSPI to bridge sync Python calls to async JS.- Chrome / Edge 137+ (May 2025): works out of the box
- Firefox: behind
javascript.options.wasm_js_promise_integration - Node 24+: pass
--experimental-wasm-jspi(vitest config already does this) - Cloudflare Workers: Python Workers with JSPI runtime
Without JSPI, reads of preloaded files still work but writes throw
RuntimeError: Cannot stack switch on close().Errors you might see
See also
python: broaderpython3builtin behavior (env, argv, stdin, exit codes)examples/typescript/pyodide/vfs.ts: runnable demo across RAM, S3, GDocs, Linear