All Projects → ethanhs → python-wasm

ethanhs / python-wasm

Licence: other
Build scripts and configuration for building CPython for Emscripten

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects
python
139335 projects - #7 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to python-wasm

Xwasm
[Work In Progress] WebAssembly Packager and WASM tooling for modern frontend
Stars: ✭ 45 (-92.57%)
Mutual labels:  wasm, emscripten
Wasmer
🚀 The leading WebAssembly Runtime supporting WASI and Emscripten
Stars: ✭ 11,047 (+1722.94%)
Mutual labels:  wasm, emscripten
Wasmjit
Small Embeddable WebAssembly Runtime
Stars: ✭ 1,063 (+75.41%)
Mutual labels:  wasm, emscripten
Deepminer
deepMiner webminer proxy (update for cryptoNight R)
Stars: ✭ 497 (-17.99%)
Mutual labels:  wasm, emscripten
Modern Wasm Starter
🛸 Run C++ code on web and create blazingly fast websites! A starter template to easily create WebAssembly packages using type-safe C++ bindings with automatic TypeScript declarations.
Stars: ✭ 140 (-76.9%)
Mutual labels:  wasm, emscripten
Cib
clang running in browser (wasm)
Stars: ✭ 685 (+13.04%)
Mutual labels:  wasm, emscripten
Opus Stream Decoder
Instantly decode Ogg Opus audio streams in chunks with JavaScript & WebAssembly (Wasm)
Stars: ✭ 80 (-86.8%)
Mutual labels:  wasm, emscripten
Wac
WebAssembly interpreter in C
Stars: ✭ 372 (-38.61%)
Mutual labels:  wasm, emscripten
Dcmjs
dcmjs is a javascript cross-compile of dcmtk (dcmtk.org).
Stars: ✭ 92 (-84.82%)
Mutual labels:  wasm, emscripten
Assortedwidgets
OpenGL GUI library
Stars: ✭ 92 (-84.82%)
Mutual labels:  wasm, emscripten
Camaro
camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser pugixml, one of the fastest XML parser around.
Stars: ✭ 438 (-27.72%)
Mutual labels:  wasm, emscripten
Webassembly Examples
From Simple To Complex. A complete collection of webassembly examples.
Stars: ✭ 177 (-70.79%)
Mutual labels:  wasm, emscripten
Edge Sql
Cloudflare Workers providing a SQL API
Stars: ✭ 429 (-29.21%)
Mutual labels:  wasm, emscripten
Cppwasm Book
📚 WebAssembly friendly programming with C/C++ -- Emscripten practice
Stars: ✭ 956 (+57.76%)
Mutual labels:  wasm, emscripten
Rustynes
👾 An NES emulator by Rust and WebAssembly
Stars: ✭ 399 (-34.16%)
Mutual labels:  wasm, emscripten
Sql.js
A javascript library to run SQLite on the web.
Stars: ✭ 9,594 (+1483.17%)
Mutual labels:  wasm, emscripten
koder
QR/bar code scanner for the Browser
Stars: ✭ 73 (-87.95%)
Mutual labels:  wasm, emscripten
Wasm Git
GIT for nodejs and the browser using https://libgit2.org compiled to WebAssembly with https://emscripten.org
Stars: ✭ 261 (-56.93%)
Mutual labels:  wasm, emscripten
Emscripten Docker
Docker image with Emscripten to compile ASM.js and WebAssembly
Stars: ✭ 92 (-84.82%)
Mutual labels:  wasm, emscripten
Squark
Rust frontend framework, for web browser and more.
Stars: ✭ 162 (-73.27%)
Mutual labels:  wasm, emscripten

CPython on WASM

Build scripts and configuration for building CPython for Emscripten.

Check out Christian Heimes' talk about the effort at PyConDE: https://www.youtube.com/watch?v=oa2LllRZUlU

Pretty straight forward. First, install emscripten. Then, run the following commands:

# get the Python sources
./fetch-python.sh
# build Python for the machine we are building on, needed before cross compiling for emscripten
./build-python-build.sh
# build Python cross-compiling to emscripten
./build-python-emscripten-browser.sh

There will probably be errors, but that's just part of the fun of experimental platforms.

Assuming things compiled correctly, you can have emscripten serve the Python executable and then open http://localhost:8000/python.html in your browser:

./run-python-browser.sh

The CLI input is done via an input modal which is rather annoying. Also to get output you need to click Cancel on the modal...

Developing

Once you've built the Emscripten'd Python, you can rebuild it via

./clean-host.sh
./build-python-emscripten-browser.sh

which will rebuild Python targeting emscripten and re-generate the python.{html, wasm, js}

Test build artifacts

You can also download builds from our CI workflow and test WASM builds locally.

Emscripten browser build

  • download and unzip the emscripten-browser-main.zip build artifact
  • run a local webserver in the same directory as python.html, e.g. python3 -m http.server
  • open http://localhost:8000/python.html
  • enter commands into the browser modal window and check the web developer console (F12) for output. You may need to hit "Cancel" on the modal after sending input for output to appear.

Emscripten NodeJS build

  • download and unzip the emscripten-node-main.zip build artifact
  • run node python.js (older versions may need --experimental-wasm-bigint)

WASI

  • download and unzip the wasi-main.zip build artifact
  • install wasmtime
  • run wasmtime run --dir . -- python.wasm
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].