{"id":22089589,"url":"https://github.com/emmatyping/python-wasm","last_synced_at":"2025-04-04T07:09:40.467Z","repository":{"id":37584245,"uuid":"432259304","full_name":"emmatyping/python-wasm","owner":"emmatyping","description":"Build scripts and configuration for building CPython for Emscripten","archived":false,"fork":false,"pushed_at":"2024-03-03T02:45:42.000Z","size":2417537,"stargazers_count":681,"open_issues_count":13,"forks_count":34,"subscribers_count":31,"default_branch":"main","last_synced_at":"2025-04-02T03:38:00.797Z","etag":null,"topics":["emscripten","python","wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://repl.ethanhs.me","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emmatyping.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-26T17:45:45.000Z","updated_at":"2025-03-22T10:40:16.000Z","dependencies_parsed_at":"2023-11-11T04:23:01.782Z","dependency_job_id":"e43f4987-c9a8-4b22-88b7-be5fd93657a7","html_url":"https://github.com/emmatyping/python-wasm","commit_stats":null,"previous_names":["emmatyping/python-wasm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmatyping%2Fpython-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmatyping%2Fpython-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmatyping%2Fpython-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmatyping%2Fpython-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emmatyping","download_url":"https://codeload.github.com/emmatyping/python-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135147,"owners_count":20889421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emscripten","python","wasm","webassembly"],"created_at":"2024-12-01T02:13:32.244Z","updated_at":"2025-04-04T07:09:40.443Z","avatar_url":"https://github.com/emmatyping.png","language":"JavaScript","readme":"# CPython on WASM\n\nBuild scripts and configuration for building CPython for Emscripten.\n\nCheck out Christian Heimes' talk about the effort at PyConDE: https://www.youtube.com/watch?v=oa2LllRZUlU\n\nPretty straight forward. First, [install emscripten](https://emscripten.org/docs/getting_started/downloads.html).\nThen, run the following commands:\n\n```shell\n# get the Python sources\n./fetch-python.sh\n# build Python for the machine we are building on, needed before cross compiling for emscripten\n./build-python-build.sh\n# build Python cross-compiling to emscripten\n./build-python-emscripten-browser.sh\n```\n\nThere will probably be errors, but that's just part of the fun of experimental platforms.\n\nAssuming things compiled correctly, you can have emscripten serve the Python executable and then open http://localhost:8000/python.html in your browser:\n\n```\n./run-python-browser.sh\n```\n\nThe CLI input is done via an input modal which is rather annoying. Also to get output you need to click `Cancel` on the modal...\n\n## Developing\nOnce you've built the Emscripten'd Python, you can rebuild it via\n\n```\n./clean-host.sh\n./build-python-emscripten-browser.sh\n```\nwhich will rebuild Python targeting emscripten and re-generate the `python.{html, wasm, js}`\n\n## Test build artifacts\n\nYou can also download builds from our [CI workflow](https://github.com/ethanhs/python-wasm/actions?query=branch%3Amain)\nand test WASM builds locally.\n\n### Emscripten browser build\n\n* download and unzip the ``emscripten-browser-main.zip`` build artifact\n* run a local webserver in the same directory as ``python.html``,\n   e.g. ``python3 -m http.server``\n* open http://localhost:8000/python.html\n* enter commands into the browser modal window and check the web developer\n  console (*F12*) for output. You may need to hit \"Cancel\" on the modal after sending input for output to appear.\n\n### Emscripten NodeJS build\n\n* download and unzip the ``emscripten-node-main.zip`` build artifact\n* run ``node python.js`` (older versions may need ``--experimental-wasm-bigint``)\n\n### WASI\n\n* download and unzip the ``wasi-main.zip`` build artifact\n* install [wasmtime](https://wasmtime.dev/)\n* run ``wasmtime run --dir . -- python.wasm``\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmatyping%2Fpython-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femmatyping%2Fpython-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmatyping%2Fpython-wasm/lists"}