• Stars
    star
    678
  • Rank 66,609 (Top 2 %)
  • Language
    JavaScript
  • Created almost 3 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build scripts and configuration for building CPython for 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

More Repositories

1

WSL-Programs

A community powered list of programs that work (and those that don't) on the Windows subsystem for Linux
CSS
1,082
star
2

cce

commandline compiler explorer - use https://godbolt.org from your terminal!
Rust
195
star
3

pyhooked

Pure Python hotkey hook, with thanks to pyHook and pyhk
Python
155
star
4

material

Material Design Widgets for PySide and PyQt4
Python
72
star
5

python-typecheckers

A list of Python type checkers (PEP 484 compliant and not, static and runtime/dynamic)
61
star
6

Explore10

Modern File Explorer
C#
29
star
7

clang

Unofficial Python bindings to libclang
Python
27
star
8

ryaml

Python yaml library using Rust
Python
24
star
9

apt.cli.rs

Issues for apt.cli.rs
23
star
10

abserde

Generate fast JSON parsers based on type stubs
Python
13
star
11

pynanosvg

Cythonic wrapper around nanosvg for rasterizing SVGs
Python
10
star
12

windows-setup

Script and description of tricks I use with my Windows setup
PowerShell
8
star
13

typycal

Generate stubs from Python code at runtime (An experiment!)
C++
6
star
14

pep-561

Issue tracker for PEP 561 with sample typed package
Python
5
star
15

mypy.app

Code for mypy.app, a mypy playground that runs in the browser!
Svelte
5
star
16

libgithub

A C++ library for use with Github's API - incomplete and very much a WIP!
C++
4
star
17

pyqml

Python C extension wrapping the minimal Qt Qml API. Still very much a WIP
QML
3
star
18

stub-package

A sample PEP 561 stub package.
Python
3
star
19

personal-puppet

My personal Puppet setup
Puppet
2
star
20

IronShell

A C# Shell replacement - Abandoned - DONT USE THIS!!
C#
2
star
21

ModernResizer

Resize and move the Windows 8 start menu
Python
2
star
22

opcodetrace

Trace CPython 3.6+ to measure opcode usage.
C++
1
star
23

upptime

My personal upptime repo
JSON
1
star
24

Kolox

An implementation of the the lox language in Kotlin to learn Kotlin and more about programming language design :)
Kotlin
1
star
25

ukkonen

A port of https://github.com/sunesimonsen/ukkonen to Rust, for use in Python
Rust
1
star
26

generational-arena-dom

A DOM implementation for html5ever that uses generational-arenas.
Rust
1
star
27

clscreate

Testing class creation times for Cython vs PyO3
Python
1
star