renpy / renpy

The Ren'Py Visual Novel Engine
http://www.renpy.org/
4.91k stars 693 forks source link

_ssl module missing, required by web builds. #5648

Closed mucski closed 1 month ago

mucski commented 1 month ago

In Ren'Py 8.2.3 if you create a web build it will give the following fatal error: ModuleNotFoundError: No module named '_ssl'

renpytom commented 1 month ago

Are you importing a library that uses it? _ssl has never been around on web builds. Do you have the full traceback?

mucski commented 1 month ago

Are you importing a library that uses it? _ssl has never been around on web builds. Do you have the full traceback?

2024-07-22 18:29:13 UTC Emscripten-3.1.24-wasm32-32bit Ren'Py 8.2.3.24061702

Full traceback: File "/renpy/bootstrap.py", line 359, in bootstrap renpy.main.main() File "/renpy/main.py", line 361, in main load_rpe(dir + "/" + fn) File "/renpy/main.py", line 156, in load_rpe exec(autorun, {'file': os.path.join(fn, "autorun.py")}) File "", line 10, in File "lib/python3.11/websockets/sync/client.py", line 4, in File "lib/python3.11/ssl.py", line 100, in ModuleNotFoundError: No module named '_ssl'

Before loading the script. ModuleNotFoundError: No module named '_ssl'

renpytom commented 1 month ago

Where is it importing websockets from?

mucski commented 1 month ago

Where is it importing websockets from?

I have no idea, it's a default renpy sdk download, with only thing installed the web module.

Kassy2048 commented 1 month ago

Look for *.rpe files in your game folder or the Ren'Py SDK folder. There is no such file in the official SDK release you're using, so it should be in your game folder most likely. If you find rpe files in the SDK folder instead, you might have downloaded the SDK from an unsafe source that added a malware to it...

mucski commented 1 month ago

Okay, got it fixed after you mentioned .rpe, it did have an .rpe in my game directory coming from a plugin called "Renpy launch and sync". If anyone comes accross that plugin, web builds wont work.

Kassy2048 commented 1 month ago

@furudean You might want to prevent the inclusion of your rpe when the game is built for Web (or at least, make it do nothing).

furudean commented 1 month ago

Thanks for mentioning me in this. This is indeed a bug in vscode-renpy-warp. I've created a ticket to track this issue in https://github.com/furudean/vscode-renpy-warp/issues/26

renpytom commented 1 month ago

I think it probably makes sense to exclude .rpe and .rpe.py files from builds. Those files are meant to extend the local install of the engine, and shouldn't go in built games.

furudean commented 1 month ago

@renpytom I agree, I'd love to not include them at all. I don't think a good mechanism to declare a .rpe file as "development only" exists in any released version. RPEs don't have access to build.classify in their executing context as it's not exported from renpy, so you have to do it in another way.

One solution could be to to add a supplemental .rpy file with build.classify("something.rpe", None) in it, but I'm not thrilled about adding more clutter to people's projects. If you have any graceful ideas, let me know.

8.3.0 already kind solves this by allowing you to put development .rpes in the Ren'Py SDK, then they won't get included. I already do this on those versions, but anything older has this problematic feature of the code being included.

renpytom commented 1 month ago

I mean, all the time. RPEs are ment to patch the engine for you, not everyone.

furudean commented 1 month ago

I don't think I follow

renpytom commented 1 month ago

Basically, .rpes aren't meant to be a way of patching the engine for players. They're really meant to let me hotfix games that already exist, and adding devlopment paches shouldn't work. But distributing a game shouldn't also distribute rpes.

furudean commented 1 month ago

Isn't the beauty of software that people will use your features in horrifying ways? ;)

distributing a game shouldn't also distribute rpes.

Fully agreed. But what other alternatives exist in <8.30? I'll opt for this hack for now, since I want to support older versions as well.

It wouldn't be a bad idea to write a .rpy file in the game directory that removes the RPE from the build, but definitely entering magic solution territory.

brunoais commented 1 month ago

@furudean I don't know how much API this is but you can add a function to the renpy.game.post_init list and then, in the callback, import store and get the function, something like:

from renpy.game import post_init
def remove_itself():
    from renpy.python import store_dicts
    store_dicts["store.build"]['classify']('**.rpe', None)

post_init.append(remove_itself)
furudean commented 1 month ago

@brunoais Nice find. I think this would be a good addition

brunoais commented 4 weeks ago

@renpytom I've been thinking. Would it be viable to add ( "**.rpe", None), to the first item in late_base_patterns instead? Regardless of the intended use of rpe files, I believe that it should be more of a "ignore by default" instead of forcefully ignore.

Just my opinion