Installation¶
p2w is a Python package that produces WebAssembly text. Running what it produces needs two more tools: wasm-tools, which assembles the text into a binary module, and a JavaScript engine with WebAssembly GC support.
Requirements¶
| Tool | Version | Needed for |
|---|---|---|
| Python | 3.12 or later | the compiler itself |
| uv | recent | installing and running p2w |
| wasm-tools | recent | assembling WAT into WASM (p2w -r, the test suite) |
| Node.js | 22 or later | running a compiled module (p2w -r, the test suite) |
| A browser with WASM GC | recent Chrome or Firefox | running a module in a page |
wabt's wat2wasm does not support the GC proposal, so it cannot assemble p2w's output: use wasm-tools.
Installing p2w¶
Install p2w from its repository:
uv sync installs p2w and its development tools into .venv. The p2w and p2w-benchmark commands are then available through uv run.
A sibling checkout
p2w depends on abilian-astero, which pyproject.toml takes from a sibling directory, ../astero. Clone it next to p2w before running uv sync.
Installing the tools¶
Then install Node.js 22 or later from nodejs.org or your package manager.
Checking the installation¶
wasm-tools --version
node --version # v22 or later
echo 'print("hello")' > hello.py
uv run p2w -r hello.py # prints: hello
Node.js versions before 22 do not enable WebAssembly GC by default, and fail to load p2w's modules.