Skip to main content

PyGame wasm for everyone

Reason this release was yanked:

pre alpha

Project description

pygbag

PyGame wasm for everyone ( packager + test server )

"your_game_folder" must contains a main.py and its loop must be async aware eg :

import asyncio
import pygame

pygame.init()
pygame.display.set_mode((320, 240))
pygame.display.set_caption("TEST")


async def main():
    count = 3

    while True:
        print(f"""

        Hello[{count}] from Pygame

""")
        pygame.display.update()
        await asyncio.sleep(0)  # very important, and keep it 0

        if not count:
            pygame.quit()
            return
        count = count - 1

asyncio.run( main() )

# do not add anything from here
# asyncio.run is non block on pygame-wasm


usage:

    pip3 install pygbag --user --upgrade
    pygbag your_game_folder

command help:

    pygbag --help your_game_folder

eg

user@pp /data/git/pygbag $ python3.8 -m pygbag --help test
 *pygbag 0.0.9*

Serving python files from [/data/git/pygbag/test/build/web]

with no security/performance in mind, i'm just a test tool : don't rely on me
usage: __main__.py [-h] [--bind ADDRESS] [--directory DIRECTORY] [--app_name APP_NAME] [--cache CACHE] [--package PACKAGE] [--version VERSION] [--build] [--archive] [--main MAIN] [--icon ICON] [--cdn CDN]
                   [--template TEMPLATE] [--ssl SSL] [--port [PORT]]

optional arguments:
  -h, --help            show this help message and exit
  --bind ADDRESS        Specify alternate bind address [default: localhost]
  --directory DIRECTORY
                        Specify alternative directory [default:/data/git/pygbag/test/build/web]
  --app_name APP_NAME   Specify user facing name of application[default:test]
  --cache CACHE         md5 based url cache directory
  --package PACKAGE     package name, better make it unique
  --version VERSION     package name, please make it unique
  --build               build only, do not run test server
  --archive             make build/web.zip archive for itch.io
  --main MAIN           Specify main script[default:main.py]
  --icon ICON           package name, please make it unique
  --cdn CDN             web site to cache locally [default:https://pygame-web.github.io/pygbag/]
  --template TEMPLATE   index.html template
  --ssl SSL             enable ssl with server.pem and key.pem
  --port [PORT]         Specify alternate port [default: 8000]

Now navigate to http://localhost:8000 with a modern Browser.

v8 based browsers are preferred ( chromium/brave/chrome ... ) because they set baseline restrictions on WebAssembly loading. using them while testing ensure proper operation on all browsers.

NOTES:

  • first load will be slower, because setting up local cache from cdn to avoid useless network transfer for getting pygame and cpython prebuilts.

  • each time changing code/template you must restart pygbag your_game_folder but cache is not destroyed.

  • if you want to reset prebuilts cache, remove the build/web-cache folder in your_game_folder

support via Discord:

https://discord.gg/t3g7YjK7rw   ( #pygame-web on Pygame Community )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygbag-0.1.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygbag-0.1.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file pygbag-0.1.0.tar.gz.

File metadata

  • Download URL: pygbag-0.1.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for pygbag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c3fcf5272cf3e856b6ed2a32a3afb8217506c79e6ef3609d776a4b3a359a756
MD5 37797d10d5f73d3f7582831467f9fc1d
BLAKE2b-256 0d194c6553c4e3e9df14d72a2dcde9a1268558e53630860555d2258911cc70fd

See more details on using hashes here.

File details

Details for the file pygbag-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pygbag-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for pygbag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87cd070988d5fb1e586bfaf0d29f489f93f0966321f93914ef858cc8f09d5f43
MD5 1cb1b2228a1f935cebc16d70608e4484
BLAKE2b-256 e4deebac3956279501cdff485e78dbbb2a5093743c8a596fcaed265e10625816

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page