Hi Everybody!
I report with a great deal of happiness that the development version of PyInstaller works very well with the latest version of PyGame. One file game deployment is now a reality for me! Thank you so much. :)
I would add this to the "Supported Packages" page myself if I had the privileges. Here are the caveats:
I get an an unknown error when using System Fonts (pygame.font.SysFont). Rather than spend the time trying to figure out the error, (I have a hunch it is something to do with paths relative to a C runtime), simply bundle a font with your game and use pygame.font.Font instead.
The rest of these workarounds require that you build and modify your .spec file yourself. If you don't know how to do this already, in short, use utils\Makespec.py and utils\Build.py. The manual has good pointers on these.
To bundle art resources with your game, the easiest way I've found is to insert a Tree entry with your art directory into the right place in the .spec file. For --onefile, that's the EXE entry. For --onedir, that's COLLECT.
Tree('\\game\\res', prefix="res\\")
When bundling resources (sprites, sounds, music) with your game, I run paths through the following code to make sure the right paths are found both when developing and when in deployment. Note this is only necessary for the --onefile distribution, which I prefer.
def resource_path(relative):
if hasattr(sys, "_MEIPASS"):
return os.path.join(sys._MEIPASS, relative)
return os.path.join(relative)
Last, when I use the --noconsole option over here, PyInstaller thinks that I'm trying to build a Macintosh app, and sticks everything inside a "
game.app" folder. This isn't really a problem, but if it annoys you, generate your .spec file without this option, and simply change the "console" argument to False inside EXE.
Thanks again for such a wonderful project. I'm over the moon! :D
-Cameron