I often write quick Python scripts that I need to run on other machines. It is sometimes easier to just drop a windows .EXE onto a machine (with a Python Interpreter compiled into it), rather than doing a full Python installation. To do this, I use py2exe.
py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs. This enables your Python scripts to be run on Windows platforms without a Python installation.
You can run py2exe directly from the command line, or you can script it. I wrote a small convenience script that I use for general compilation.
Let's call the compilation script: compile.pyLet's say we have a script we want to compile named: foo.py
You would then invoke it from the command line like this:
This will create a 'dist' subdirectory containing the newly created executable along with some necessary DLL's.
Here is the code I use for my compile.py:
(note: you need to have Python and py2exe installed on a Windows box to run this)
Copyright © 2006-2008 Corey Goldberg
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.