libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
409 stars 36 forks source link

Packaging with PyInstaller #42

Closed nightblade9 closed 6 years ago

nightblade9 commented 6 years ago

I recently tried to package my TDL game with PyInstaller, and ran into several issues. Has anyone managed to get this working? I found some PyInstaller+Libtcod tutorials, but they don't seem to work with TDL.

If not, maybe this issue can capture some of the problems and solutions to get this to work. Or does this issue belong on the PyInstaller repo? It seems like it should be here, because it's a question of "how to make this work with PyInstaller." Let me know if I should close it.

1) SDL2.dll is not automatically included in the package; you get this output: WARNING: lib not found: SDL2.dll dependency of d:\python\python36-32\lib\site-packages\tcod\_libtcod.cp36-win32.pyd.

When you run the executable, you get a runtime error: ImportError: DLL load failed: The specified module could not be found.

This can be remedied by adding it to the binaries section of the spec file: ('C:\path\to\tdl\sdl2.dll', '')

I seem to be running into encoding issues with my spec file right now, so I'll edit in the second issue once I can again get this to work.

HexDecimal commented 6 years ago

You mostly just need to grab the hook from the PyInstaller example: https://github.com/HexDecimal/python-tdl/tree/master/examples/distribution/PyInstaller

nightblade9 commented 6 years ago

It works, if you copy the assets file. It looks like the instructions were missing a key step (downloading the hook file), so I opened a PR.

Sorry, I'm not exactly a Python pro -- it's probably an obvious step but it wasn't obvious to me.