A journeyman programmer who has been trying for years to be a game developer. Having never release anything more than several weak tech demos, the quest has a ways to go. A recent discovery of game competitions show hope of a fresh start at being less of a coder and more of a game creator.

Report RSS Development - Python Game Packager

Posted by on

Purpose
Due to the barrier of entry being dropped for computers, gamers have come to expect the ability to download and run a game in just a handful of clicks. Apparently a .zip of source code is scary enough to prevent a large percentage of gamers from even trying the first room of your game. In this blog I'm going to describe a problem I've personally had with Python game development in relation to distribution, and a tool I've started to work around it.

Java
One of the things I really liked about Java game development was how easy it was to distribute a game demo. Both game libraries I used (LWJGL and LibGDX) could be nested into a .jar file with all native dependencies. From the comfort of Eclipse on an Linux computer I could build a single .jar file that would play my game the same there as any Windows or Mac computer. This means all Windows and Mac users could play the game demos with no extra time or effort.

Python
Python code is just as easy to write in a cross-platform fashion, but preparing a single file for "no questions asked" execution is a bit rougher. A game could be distributed as a series of scripts, but that requires the gamer to have a Python interrupter installed and enough knowledge to correctly install/run the scripts. This is way too much work and responsibility to expect any non-developer to deal with.

A package exists called PyInstaller that can take the collection of game scripts mentioned above and build a "one file" executable from them. Unfortunately the package can only prepare an executable for the platform it is being run from. So this means if I were to run PyInstaller on the same Linux computer that I've written the code, then I would get an executable that would only work on Linux. This is the tool I've been using manually to prepare a single Windows executable to go with any game I've released in the last year.

Fortunately with some modern tooling it shouldn't be too hard to build an automated pipeline that would perform this build process on many different platforms simultaneously.

Packager
While I was gone at a software conference last week for work I started building a custom tool to perform this automation. The tool takes the form of a Flask website with a simple HTML form for submitting game source code. On the server side, the source is built into an executable using PyInstaller and packaged back up with any art assets. Once built I should be able to setup multiple instances of the site; one for each of the platforms I would like to support. Then when I'm ready to release a new version of a game, I use these sites to quickly generate releases for platforms different than my development box.

Web form with package details filled out.

Web form with package details filled out.

I hope to share some more development progress soon as I wrap up the first version of the tool. I'll release source code as usual when that first version gets developed. Leave a comment if you've ever had a difficult time packaging a game release. Were you ever able to automate that process? Or did the tooling just get better?

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: