python package/program distribution methods


distutils
http://www.python.org/doc/current/dist/simple-example.html
发布python package,(.py, .pyc, .pyo等,不能单独运行,需要安装python运行环境)

setup.py文件内容:
from distutils.core import setup
setup(name=’foo’,
          version=’1.0’,
py_modules=[‘foo’],
          )

python setup.py sdist —-> source distribution
python setup.py bdist_wininst —-> 将python module以windows安装文件的形式发布,安装后原python源文件、编译后的
.pyc, *pyo文件将被安装到python安装目录下的Libsite-packages
python setup.py bdist_rpm

py2exe
py2exe是一种python发布工具,可以把python脚本转换成windows下的可执行程序,不需要安装python便可运行。
py2exe安装后的文件应该在你的python安装目录下的Libsite-packagespy2exe

运行下面命令即可
python setup.py py2exe -b2

setup.py文件内容:
from distutils.core import setup
import py2exe
setup(console=[‘hello.py’])

python setup.py –help py2exe
–xref (-x)         create and show a module crosss reference
–bundle-files (-b)   bundle dlls in the zipfile or the exe. Valid levels are 1, 2, or 3 (default)