Web Export
Ajishio projects can be exported to run in the browser via pygbag. No changes to your game code are required.
Usage
From the repository root:
uv run pygbag_export.py demo_projects/sokoban
This starts a local test server at http://localhost:8000. Open it in a Chromium-based browser (Chrome, Edge, Brave) for best results.
Other useful flags:
# Build only, don't start the server
uv run pygbag_export.py demo_projects/sokoban --build
# Build a zip you can upload to itch.io
uv run pygbag_export.py demo_projects/sokoban --build --archive
Output goes to <your_project>/_web_build/.
What the export script does
The script takes care of everything so you don't have to think about it:
- Copies your project into a temporary build directory (your source files are never modified)
- Bundles the ajishio library alongside your project
- Patches the copied
main.pyfor the browser:- Adds
import pygameso pygbag downloads the pygame-ce WebAssembly wheel - Adds
import asyncioif not already present - Swaps
aj.game_start()→asyncio.run(aj.async_game_start())so the game loop yields to the browser every frame
- Adds
Debugging
If you see a blank grey screen, append ?-i to the URL
(e.g. http://localhost:8000?-i). This opens a Python terminal at the
bottom of the page where you can see tracebacks and print output.
Known limitations
cProfiledoesn't exist in WebAssembly. Ajishio handles this internally, but avoid importingcProfileorpstatsdirectly in your game code.from __future__ import annotations— add this to yourmain.pyif you use type hints behindif TYPE_CHECKINGguards. pygbag evaluates annotations eagerly.