Having used py2exe on a few occasions, each time I’ve stumbled over how to make it include additional data files and exes that my Python code depends on.
I’m writing this entry for personal reference and, just perhaps, I can save someone else the trawl through the docs.
py2exe is a breeze – I’ve used it on Python2.4 and Python2.5 and it ‘just works’ for basic Python code. It works fine with easygui and TKinter code, I’ve had a few troubles with math code (matplotlib, Numpy) but mostly I’ve been able to fix them.
Each investigation took less than 30 minutes and I easily recommend py2exe to distribute Python code.
For reference – see here to add configuration files to the resulting distribution. The ‘configuration files’ can be any files – data, exes, images – whatever you need to include.
You add these files by specifying a list of tuples. Each tuple specifies the destination subdirectory (e.g. ” or ‘destinationDirName’), followed by a list of strings of files to copy.
Here is a simple example – you run it using ‘python setup.py py2exe’ at the commnd prompt.
from distutils.core import setup
# run 'python setup.py py2exe' at command line
# to build the 'dist' distribution directory