Inside Look – py2exe

Early on in development, I immediately recognized the need for The First Fantasy to be easy distributed and ran without handing over a load of source files and asking the user to build them and also have the Python interpreter on their machine. This is where py2exe came in for me.

py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.

The output from using the utility is what I zip and make available in the Downloads page. Nifty huh? All that’s needed is to create a simple file in your working source directory with the following:

from distutils.core import setup
import py2exe


Then, through a batch file or command line, execute both of the commands:

python install
python py2exe

Py2exe will create a build and dist directory. The build directory can be discarded, but the dist directory contains everything needed (besides possibly a couple .dlls that the user should have) to run the program. Numerous options exist that allow you to modify the output such as renaming the executable, choosing where to place the dist directory, and several optimization options.

Tagged ,

2 thoughts on “Inside Look – py2exe

  1. emmyleigh says:

    What version of python are you using, and what editor?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: