From dc03437b73f36608a1788dba3d53c8c4f0cde983 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Thu, 15 Aug 2024 08:56:18 +0200 Subject: [PATCH] prepare ini page --- README.md | 3 ++- wiki/pygbag-configuration/README.md | 5 +++++ wiki/pygbag-internals/README.md | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 wiki/pygbag-configuration/README.md create mode 100644 wiki/pygbag-internals/README.md diff --git a/README.md b/README.md index 2a62abe..426ec0b 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Useful .gitignore additions: /dist ``` +[controlling pygbag packing and options from pygbag.ini](/wiki/pygbag-configuration) ## Coding @@ -113,7 +114,7 @@ When importing non-stdlib packages (for example, numpy or matplotlib), you must - While working, you can access the simulator of the web loop by replacing `import asyncio` by `import pygbag.aio as asyncio` at top of main.py and run the program from the folder containing it. - TODO: Android remote debugging via [chromium browsers series](https://developer.chrome.com/docs/devtools/remote-debugging/). - TODO: Universal remote debugging via IRC Client or websocket using pygbag.net. - +- [pygbag runtime ?](/wiki/pygbag-internals) There's number of command line options : read Pygbag's [project description](https://pypi.org/project/pygbag/) for a more detailed overview. diff --git a/wiki/pygbag-configuration/README.md b/wiki/pygbag-configuration/README.md new file mode 100644 index 0000000..2cadd46 --- /dev/null +++ b/wiki/pygbag-configuration/README.md @@ -0,0 +1,5 @@ + +TODO: pygbag.ini + + +[Edit this page](https://github.com/pygame-web/pygame-web.github.io/edit/main/wiki/pygbag/configuration/README.md) diff --git a/wiki/pygbag-internals/README.md b/wiki/pygbag-internals/README.md new file mode 100644 index 0000000..4b4d02b --- /dev/null +++ b/wiki/pygbag-internals/README.md @@ -0,0 +1,16 @@ + +When running in the webpage pygbag is in fact a C runtime linked to libpython ( cpython-wasm from python.org) compiled to WebAssembly with emscripten compiler and hosted on a CDN (pygame-web.github.io). It is downloaded once per game and per version update for fast local use. + +There's some javascript glue to connect the C library used by pygbag and python to some file descriptors. You cannot guess the mechanism that easily because calls originate from wasm cpu which is not exposed in javascript console. + +Those file descriptors manipulated by the libc (musl provided by emsdk the portable emscripten compiler) can be in a virtual filesystem hosted by MEMFS from emscripten runtime ( eg for /tmp ) or BrowserFS a more advanced virtual filesystem ( /data and /usr ). + +They can also be stdin/stdout/stderr file descriptors and this is why you can find the file on startup : the python part of html file is sent to python interpreter as if you typed it in your shell this is done by calling PyRun_InteractiveLoop on that file descriptor. + +Later if a file "main.py" is found in the Virtual filesystem it is queued but you can also pass relative file url on the command line eg https://pygame-web.github.io/showroom/pypad.html#src/test_panda3d_cube.py. It also work with github gist raw links. pygbag can also embed code or git repo eg https://pygame-web.github.io/showroom/test_embed_git.html directly in html pages. + +Some packages like pygame-ce, Panda3D or Harfang3D are indeed pre-compiled to WebAssembly and that's because they are mostly C or C++. + +Python code is actually interpreted and type-annotated code could be compiled direcly to Wasm but that fonctionnality is not (yet) available for public use. + +The format choosen for game archive is a zip file similar to android APK though unaligned and unsigned. The android runtime to make these run on real android is not (yet) available for public use either.