Luau packaged as a Pyodide WebAssembly wheel
Project description
luau-wasm
Luau packaged as a Python extension for Pyodide.
This project demonstrates publishing a WebAssembly wheel to PyPI. The wheel contains a compiled CPython extension module that embeds the Luau compiler and VM. In Pyodide 314, micropip can install that PyPI wheel directly in the browser.
Try the playground: https://simonw.github.io/lua-wasm/
Installation
In Pyodide:
import micropip
await micropip.install("luau-wasm")
import luau_wasm
print(luau_wasm.execute('print("Hello from Luau")'))
In JavaScript with Pyodide:
await pyodide.loadPackage("micropip");
await pyodide.runPythonAsync(`
import micropip
await micropip.install("luau-wasm")
import luau_wasm
`);
pyodide.globals.set("source", 'print("Hello from Luau")');
const output = pyodide.runPython("luau_wasm.execute(source)");
Python API
import luau_wasm
output = luau_wasm.execute("""
local name = "Luau"
print(`Hello from {name}`)
""")
assert output == "Hello from Luau\n"
execute(source) creates a fresh sandboxed Luau state, runs the source, captures print() output, and returns that output as a Python string.
Compile and runtime failures raise luau_wasm.LuauError:
try:
luau_wasm.execute('error("boom")')
except luau_wasm.LuauError as ex:
print(ex)
run is an alias for execute.
Building
This repository vendors the minimal Luau source needed by the extension in vendor/luau/.
To update the vendored Luau source:
scripts/vendor-luau.sh
To run native tests (which use a native build, not the WASM build):
uv run python -m pytest
To build the Pyodide WebAssembly wheel:
scripts/build-pyodide-wheel.sh
That runs:
uv run --with pyodide-build pyodide build .
The expected wheel target for Pyodide 314 / Python 3.14 is:
cp314-cp314-pyemscripten_2026_0_wasm32
To build using cibuildwheel:
CIBW_PLATFORM=pyodide uv run --with cibuildwheel cibuildwheel
Publishing
Pyodide 314 implements the standardized PyEmscripten platform tags described by PEP 783.
The GitHub Actions publish workflow builds the Pyodide wheel with cibuildwheel.
Development Notes
The extension is intentionally small:
native/_luau.cppprovides the CPython wrapper and output capture.setup.pycompiles Luau.Common, Luau.Ast, Luau.Bytecode, Luau.Compiler, and Luau.VM into the extension.docs/index.htmlis a GitHub Pages playground that loads Pyodide, installsluau-wasmfrom PyPI withmicropip, and executes Luau code through Python.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file luau_wasm-0.1a0-cp314-cp314-pyemscripten_2026_0_wasm32.whl.
File metadata
- Download URL: luau_wasm-0.1a0-cp314-cp314-pyemscripten_2026_0_wasm32.whl
- Upload date:
- Size: 271.6 kB
- Tags: CPython 3.14, PyEmscripten 2026.0 wasm32
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15c352440d63b9d5d7c9b4ebf6970526de3f1ed80525105b7944833767d6824e
|
|
| MD5 |
8f73030c7ebbbc6a2d9bd22a34efae09
|
|
| BLAKE2b-256 |
51e780bf252bb7796fda3115aceadf1dba26448e0bf5d05fafc884cd83a9e792
|
Provenance
The following attestation bundles were made for luau_wasm-0.1a0-cp314-cp314-pyemscripten_2026_0_wasm32.whl:
Publisher:
publish.yml on simonw/luau-wasm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
luau_wasm-0.1a0-cp314-cp314-pyemscripten_2026_0_wasm32.whl -
Subject digest:
15c352440d63b9d5d7c9b4ebf6970526de3f1ed80525105b7944833767d6824e - Sigstore transparency entry: 1810570124
- Sigstore integration time:
-
Permalink:
simonw/luau-wasm@bdf01bd53557b0db6ca4e604e09a62e95a4e33c8 -
Branch / Tag:
refs/tags/0.1a0 - Owner: https://github.com/simonw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bdf01bd53557b0db6ca4e604e09a62e95a4e33c8 -
Trigger Event:
release
-
Statement type: