The py2exe Tool
The distutils help you
package up your Python extensions and applications. However, an end
user can install the resulting packaged form only after installing
Python. This is particularly a problem on Windows, where end users
want to run a single installer to get an application working on their
machine. Installing Python first and then running your
application’s installer may prove too much of a
hassle for such end users.
Thomas Heller has developed a simple solution, a
distutils add-on named py2exe,
freely available for download from http://starship.python.net/crew/theller/py2exe/.
This URL also contains detailed documentation of
py2exe, and I recommend that you study that
documentation if you intend to use py2exe in
advanced ways. However, the simplest kinds of use, which I cover in
the rest of this section, cover most practical needs.
After downloading and installing py2exe (on a
Windows machine where Microsoft Visual C++ 6 is also installed), you
just need to add the line:
import py2exe
at the start of your otherwise normal distutils
script setup.py. Now, in addition to other
distutils commands, you have one more option.
Running:
python setup.py py2exe
builds and collects in a subdirectory of your distribution root
directory an .exe file and one or more
.dll files. If your
distribution’s name metadata is,
for example, myapp, then the directory into which
the .exe and .dll files are
collected is named
dist\myapp
\. Any files
specified by option data_files in your ...