-
-
Notifications
You must be signed in to change notification settings - Fork 857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to embed Python for web version Pyxel #412
Comments
PyO3 can statically embed the python interpreter, but it is complicated. Also, as I know, no one succeeds to link it to the wasm target. In summary:
*Unfortunately, PyO3 does not support PyO3. See also: michaelwooley/pybros#32 |
Thank you for the information. |
I am also investigating here to understand how PyGame realizes WASM feature. |
Another possibility. I'm wondering whether it will be linked statically and Pyodide support Maturin to build an embedded package. |
Would you prefer something like pyxel-script ( based on pygame-script the newest addition to pygbag ) ? a pygame-script example : https://pygame-web.github.io/showroom/pygame-scripts/org.pygame.touchpong.html i don't think that loading the wheel dynamically will loose much performance vs a static build but i would need a benchmark code to be sure.
That is only the normal python build + emsdk packaged for CI, pygame uses a static build, and the i also apply the same to Panda3D or Harfang3D but it may not be necessary to add that complication for Pyxel thanks to the abi3 ** edit i merged pygame and loader build into pygbag repo |
I cleaned up the Pyodide-related code in Pyxel. |
@pmp-p Thank you for your suggestion. Pyxel-script with very simple tags sounds attractive. |
There's the easy way : letting pygbag do what it does for pygame games and just open() the assets after waiting they are mounted and browser preloaded them ( that's the green progress bar you can see on some games on demos/itch ) Or the async way and get assets one by one from server asynchronously ( like pyodide fetch ) and preload manually each new asset . Preloading is annoying unless you use a SDL2_image > 2.6 (pygbag does) which uses stbimage and nanosvg internally. or just mix the two methods and everyone will pick for their needs ! ( that's the default in pygbag once .apk is mounted in filesystem and asyncio.run(main()) has started running but for that i rely on two builtins modules that are NOT part of cpython or pyodide see https://discuss.python.org/t/status-of-wasm-in-cpythons-main-branch/15542/12?u=pmp-p ) i really hope theses modules get considered for inclusion in 3.12, instead of having to slap around thousands lines of typescript and js glue each time you want to do a fetch, network/webrtc or just query battery/accelerometer/webusb/web audio etc ... => if you happen to think the same, just make your voice heard |
@pmp-p Thank you for your response. In that case, Pyxel already has "pyxapp" format which includes scripts and assets as single zip. And Pyxel can play it from JavaScript with its JavaScript utility function now. So I did the most of what I could, I think. |
perfect ! you could use pygame-script to mount them directly like here https://github.com/pygame-web/pygbag/blob/2aae0ac269aeeb9c377d91ca0b9f82ca165ad0e6/static/default.tmpl#L87 after that they are synchronously available ( and writeable : editors may like that ! ) from python via normal filesystems files. |
Does anyone know whether it is possible to embed libpython for WASM on PyO3? |
Now Pyxel Web works stably with its custom HTML elements. And I never heard performance issue from users. |
The initial web version of Pyxel is built as wheel and worked with (patched) Pyodide.
But I'd also like to consider embedding-Python-version like PyGame WASM.
The difference between Pyxel and PyGame is Pyxel uses Rust, PyO3, and Maturin.
I'd like to know how to modify the way to use them for embedding Python WASM.
I'm not familiar with Emscripten-related area, so any information would be appreciated!
The text was updated successfully, but these errors were encountered: