Game Development Reference
In-Depth Information
script and setup.py. From that folder, type " c:\Python26\python.exe
setup.py py2exe ". The first part ( c:\Python26\python.exe ) runs the Python
interpreter from the command line. The first command line option ( setup.py ) is the
script that the interpreter should run. The second command line option ( py2exe ) tells the
script to run with the py2exe option.
There will be a large amount of text from running this program. You can ignore this text.
When the compilation is finished, there will be two new folders, named build and dist.
You can delete the build folder because it only contains files that were used during
compilation. The dist folder contains all the files you want to give to other people,
including the hello.exe binary executable. (Your executable may have a different name. If
your setup.py had hello.py, then compilation produces a program named hello.exe.)
Step 4: Distribute Your Program
It's not easy to email all the files in the dist folder to someone. You can use a "zip
program" to package these many files into one file (called a zip file because it has the
extension .zip). Zip programs can be downloaded from the Internet for free. Some popular,
free zip programs are:
Zip Software
Website
7-zip
http://www.7-zip.org/download.html
WinRAR
http://www.rarlab.com/download.htm
You can rename the dist folder to something else if you wish. The files simply have to be
in the same directory.
Summary
The process for turning your .py Python scripts into .exe binary executable programs for
Windows is simple:
Step 1: Download and install py2exe from http://sourceforge.net/projects/py2exe/files/
Step 2: Create a setup.py file that looks like this:
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
Step 3: Run " c:\Python26\python.exe setup.py py2exe "
Step 4: Package up the dist folder into a zip file.
Search WWH ::




Custom Search