BETA (Everything is subject to change)
Pronounced "pie-go-died", pygodide is a tool for converting Pygame projects into web applications using Pyodide. It provides a simple command line interface and works by analyzing your code and asset files and then building them together with some web-specific glue code to make everything work in the browser.
Thanks to Pyodide, pygodide supports far more Python packages than just Pygame.
Documentation: https://elan456.github.io/pygodide/
pip install pygodidegit clone https://github.com/Elan456/pygodide.git
cd pygodide
uv sync --devpygodide build /path/to/your/pygame/project --serveThat's it! Open http://localhost:8000 in a web browser to see your app running. Currently only supports flat projects. The vision is to support any arbitrary pygame project.
You can also add dependencies directly from the CLI:
pygodide build /path/to/your/pygame/project \
--dep pygame-ce \
--dep fastquadtreepygodide build now merges dependencies from these sources:
requirements.txt[project].dependencies[tool.pygodide].dependencies- dependency groups named in
[tool.pygodide].dependency-groups - repeated
--depflags
Later sources override earlier ones when the same package is declared more than
once. The build command prints the sources it used and whether each dependency
was assigned to pyodide.loadPackage(...) or micropip.install(...).
Example:
[project]
name = "my-game"
version = "0.1.0"
dependencies = ["numpy>=1.26"]
[dependency-groups]
web = ["pygame-ce"]
[tool.pygodide]
app = "main:web_main"
dependencies = ["fastquadtree"]
dependency-groups = ["web"]Install the local hooks once after cloning:
uv run pre-commit install --hook-type pre-commit --hook-type pre-pushRun the same checks as CI locally:
uv run ruff format --check .
uv run ruff check .
uv run pytestUse pygodide smoke to build an app, serve it locally, and launch it in a
headless Chromium browser:
uv run playwright install chromium
uv run pygodide smoke /path/to/your/pygame/projectThis command does not require any extra manifest file in your app. It uses the
same build configuration as pygodide build, so pyproject.toml,
requirements.txt, --app, and repeated --dep flags work the same way:
uv run pygodide smoke /path/to/your/pygame/project \
--app main:web_main \
--dep pygame-ceThe default smoke test passes when the generated page loads, no browser console
or page errors occur, and the bootstrap emits the deterministic
[pygodide] ready console log. It is intentionally a launch check, not a
screenshot suite.
For a faster build-only check that does not launch a browser:
uv run pygodide smoke /path/to/your/pygame/project --build-onlyThe repository includes smoke-test fixtures under test_targets/. Each direct
child directory is treated as one target and must contain a
testing_manifest.yaml manifest. This file is only for pygodide's own test
fixtures; end-user projects do not need it.
name: ball-bouncing
description: Small pygame app with a bouncing ball and keyboard input.
smoke:
path: /
ready-log: "[pygodide] ready"
timeout-ms: 120000
post-ready-ms: 500The only required field is name. Optional build metadata can override the
entrypoint or add CLI-style dependencies without changing the target's
pyproject.toml:
build:
app: launcher:start
deps:
- pygame-ceRun the full fixture suite locally with:
uv run playwright install chromium
./scripts/smokeFor a faster manifest-plus-build check that does not launch a browser:
./scripts/smoke --build-onlyRun one target by manifest name with:
./scripts/smoke --target ball-bouncingtest_targets/ball_bouncing contains a small Pygame app.
Using the following command, you can build and serve the app in a web browser:
pygodide build test_targets/ball_bouncing --serveYou'll get the output of:
Serving /home/ethan/Projects/pygodide/test_targets/ball_bouncing/build at http://localhost:8000Open http://localhost:8000 in a web browser to see the app running. You should see a bouncing ball! Press the arrow keys to accelerate the ball in different directions.