py2exe
distutils helps you package 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 you study this documentation if you intend to use py2exe in advanced ways. However, the simplest uses, which I cover in the rest of this section, cover most practical needs.
After downloading and installing py2exe (on a Windows machine where Microsoft VS 2003 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 setup.py script are placed in subdirectories ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access