Packaging a Python game for end-users

Started by
0 comments, last by Katie 8 years, 2 months ago

Hi there. I have a small game that I have written in Python using the Pygame library. I'm now banging my head against a wall because I am having significant trouble trying to figure out how users can install my game. I currently am using the default setuptools method of Python distribution but it always errors out when trying to downloads the Pygame dependancy. Since Pygame is not on PyPI, it has to be downloaded from its Git repo, and it will not install it.

Here is my setup.py script:


from setuptools import setup

setup(
	name = 'SpaceInvaders',
	description = 'Its space invaders...',
	packages = ['spaceinvaders'],
	package_data = {'spaceinvaders': ['data/*']},
	install_requires = ['pygame'],
	dependency_links = ['https://bitbucket.org/pygame/pygame'],
)

It fails to install pygame every time.

I have also tried freezing tools like py2exe and pyInstaller. However, every example I can find only deals with a single .py file. My game is a package with about 7 .py files including an __init__.py and a __main__.py. I have not been able to find any info on how to build an entire package like this into a .exe.

Any help is greatly appreciated. Thank You.

Advertisement

We've been using twitter's Pex to build our software so that we don't have library dependencies on our production machines. The target stills need to install the right version of Python itself (2.7, say) but you can ship all the other pieces in a single blob -- in this case including your known-good version of pygame and so on.

(They're basically zip archives with a header on them that starts a python interpretation -- when you try and import stuff, it'll look in the zip first before looking on the system.)

Pex itself is being ropey and a pain at the moment with 2.7[1], but the PantsBuild project will compile PEX objects for you (and is also a much nicer way of expressing all the dependencies; it's based on Google's BUILD file system). PantsBuild will boot itself with relatively little work.

(It IS possible to build cross-platform PEXes which will run on PY26 and PY27 hosts, but it's hacky)

[1] I think because the twitter devs are moving to PantsBuild.

This topic is closed to new replies.

Advertisement