Skip to content
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 add a (stdlib) module? #85

Closed
raventan95 opened this issue Apr 16, 2023 · 4 comments
Closed

How to add a (stdlib) module? #85

raventan95 opened this issue Apr 16, 2023 · 4 comments

Comments

@raventan95
Copy link

Python 3.10
Pygbag 0.7.1

Trying to run pygbag on a pygame, in debug windows see stdlib module optparse not found.
I did not use the module anywhere in my code, not sure why pygbag needs it??? I don't know how to disable importing this module

So, I try copy these 3 files from stdlib installation path to the folder containing main.py.
image

It work! but another module not found, this time is regex. Again, I did not use this module anywhere in my code, so not sure why pygbag needs it.

I try to do the same thing, by copying these files to main.py, but it did not work this time :(
image

I understand I can request the package to be included in #63 , but this is stdlib, surely others will face the same problem?

This is the debug terminal logs

sys._emscripten_info(emscripten_version=(3, 1, 33), runtime='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36', pthreads=False, shared_memory=False)
pygame-ce 2.1.4.dev1 (SDL 2.24.2, Python 3.11.2)
284: assets found : 0
341: EventTarget delayed by loader
622: possibly synchronous code found
1020: import scan filename='<stdin>' len(code)=391 ['nltk', 'numpy', 'game', 'settings']
1044: requesting module want='nltk' for file='<stdin>' 
1055: module want='nltk' requested
1044: requesting module want='numpy' for file='<stdin>' 
1055: module want='numpy' requested
1044: requesting module want='game' for file='<stdin>' 
1063: repo['-CDN-']='http://localhost:8000/archives/repo/' does not provide want='game'
1044: requesting module want='settings' for file='<stdin>' 
1063: repo['-CDN-']='http://localhost:8000/archives/repo/' does not provide want='settings'
1202: want='numpy' found : True
pkg : http://localhost:8000/archives/repo/pkg/numpy-1.22.4-cp311-cp311-wasm32_mvp_emscripten.whl
 |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| 100.0% 
1202: want='sqlite3' found : False
PKG NOT FOUND : want='sqlite3', resume=None, ex=None
1202: want='regex' found : False
PKG NOT FOUND : want='regex', resume=None, ex=None
1291: {req=} in {cls.ignore=} or sys.modules
1202: want='nltk' found : True
pkg : http://localhost:8000/archives/repo/pkg/nltk-3.7-py3-none-any.whl
 |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| 100.0% 
646: starting shell
996: 20 lines queued for async eval
going interactive
643: TODO detect input/print to select repl debug
181: FIXME dependency table for manually built modules
1202: want='regex._regex_core' found : False
PKG NOT FOUND : want='regex._regex_core', resume=<function <module> at 0xfee300>, ex=ModuleNotFoundError("No module named 'regex._regex_core'; 'regex' is not a package")

Also, I have 2 local imports which my main program will import scripts from, the directory tree looks like

groword
 |-- game.py
 |-- settings.py
 |-- main.py

Will this also cause problem because I see repo['-CDN-']='http://localhost:8000/archives/repo/' does not provide want='game'

@pmp-p
Copy link
Member

pmp-p commented Apr 17, 2023

you can add modules directly in the game folder, all extra modules that may be imported by submodules must be imported first in main.py

nltk requires regex module which is not provided yet. You should make a request for it in https://github.com/pygame-web/pkg-porting-wasm

@raventan95
Copy link
Author

Thanks @pmp-p

May I know why nltk module is already provided in pkg-porting-wasm, but not regex? How can one use nltk if the module will always import regex? So, strictly speaking, nltk is also not supported yet?

Also, is socket module supported? I want to make pygame on pygbag run as a multiplayer game

@pmp-p
Copy link
Member

pmp-p commented Apr 22, 2023

regex ( wheel from pyodide 3.11 python-wasm-sdk build ) is now staging, but i see that nltk also require xml.sax which is not in the minimal stdlib runtime so you will need to copy it from a full 3.11 stdlib

client sockets are supported, that means server must use websocket protocol or lives behind a tool like websockify

@pmp-p
Copy link
Member

pmp-p commented Sep 26, 2023

most of stdlib should not be required to make games, extra modules - if not games engines - are outside pygbag scope for now.

@pmp-p pmp-p closed this as completed Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants