Skip to main content

Luau packaged as a Pyodide WebAssembly wheel

Project description

luau-wasm

PyPI Tests Changelog License

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.cpp provides the CPython wrapper and output capture.
  • setup.py compiles Luau.Common, Luau.Ast, Luau.Bytecode, Luau.Compiler, and Luau.VM into the extension.
  • docs/index.html is a GitHub Pages playground that loads Pyodide, installs luau-wasm from PyPI with micropip, and executes Luau code through Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

luau_wasm-0.1a0-cp314-cp314-pyemscripten_2026_0_wasm32.whl (271.6 kB view details)

Uploaded CPython 3.14PyEmscripten 2026.0 wasm32

File details

Details for the file luau_wasm-0.1a0-cp314-cp314-pyemscripten_2026_0_wasm32.whl.

File metadata

File hashes

Hashes for luau_wasm-0.1a0-cp314-cp314-pyemscripten_2026_0_wasm32.whl
Algorithm Hash digest
SHA256 15c352440d63b9d5d7c9b4ebf6970526de3f1ed80525105b7944833767d6824e
MD5 8f73030c7ebbbc6a2d9bd22a34efae09
BLAKE2b-256 51e780bf252bb7796fda3115aceadf1dba26448e0bf5d05fafc884cd83a9e792

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page