GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - emmatyping/python-wasm: Build scripts and configuration for building CPython for Emscripten

BranchesTags
Open more actions menu

Latest commit

 

History

94 Commits
94 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.github
.github
 
 
browser-ui
browser-ui
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
build-python-build.sh
build-python-build.sh
 
 
build-python-emscripten-browser.sh
build-python-emscripten-browser.sh
 
 
build-python-emscripten-node.sh
build-python-emscripten-node.sh
 
 
build-python-wasi.sh
build-python-wasi.sh
 
 
clean-host.sh
clean-host.sh
 
 
fetch-python.sh
fetch-python.sh
 
 
run-python-browser.sh
run-python-browser.sh
 
 
run-python-node.sh
run-python-node.sh
 
 
run-python-wasi.sh
run-python-wasi.sh
 
 
test-emscripten-node.sh
test-emscripten-node.sh
 
 
test-wasi.sh
test-wasi.sh
 
 

Repository files navigation

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

About

Build scripts and configuration for building CPython for Emscripten

Topics

emscriptenpythonwasmwebassembly

Resources

Readme
Activity

Stars

683 stars

Watchers

30 watching

Forks

34 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.