Skip to main content
wasi runs CPython in WebAssembly, with the standard library available subject to the restrictions below. Programs can access workspace files under the same permissions as shell commands, but cannot access host files or the network. Python SDK only.

Installation

Download and unzip a release from cpython-wasi-build. Point home, or MIRAGE_WASI_HOME, at the unzipped directory.

Usage

Memory

max_memory caps the memory one run may grow to:
A run that needs more raises MemoryError. CPython starts at about 40M, so a cap below that fails every run. There is no cap by default.

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.

File objects

Reads fetch ranges from the mount as the program asks for them.

os

File operations

os.read() and os.pread() fetch ranges from the mount as the program asks.

Directory operations

Environment and working directory

os.path

pathlib

sys

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.

json

glob

shutil

subprocess

Process creation is unavailable in this runtime.

socket

Network connections are unavailable in this runtime.

Notes

  • Each command starts with fresh Python state. Files saved to workspace mounts persist between commands.
  • Exit codes are limited to 0–255.
  • Empty-path behavior depends on the Python build. Use . for the current directory.
  • A workspace mount at /lib or any path starting with /lib/python makes python3 exit 126 to protect the interpreter’s standard library. Other paths under /lib, such as /lib/app, are fine.