Thursday, May 28, 2009

[Python] py2exe

For most of windows users, they don't like to install several packages for only one program. In this way, programmers might distribute their software as an executable file for windows platform. In python, we can use py2exe to convert our project as win32 application.

py2exe official website

http://www.py2exe.org/


Before running py2exe, you should install .net framework in your system

Microsoft .NET Framework 3.5 Service Pack 1


Here I take "PyQtCodeGenerator" for example:
setup.py
#! /usr/bin/python

from distutils.core import setup
import py2exe

setup(windows=[{"script":"PyQtCodeGenerator.py"}], options={"py2exe":{"includes":["sip"]}})


Put the 'setup.py' under 'PyQtCodeGenerator' folder, and typing following command for converting

python setup.py install

After waiting fews seconds, you will see lots of runtime essential files inside the 'dist' folder.

So far, py2exe can only support windows platform, so please do not use it on your linux system.

Or, you can write a py2bin for lots of python programmers.

0 意見:

Post a Comment