: Python compiler in Python,一个用纯Python写的Python的bytecode编译器,可以优化输出的pyc文件。
和PyPy一样,现在还看不出对发布Python程序的直接好处。只有py24的bytecode。
pyc是pyvm这个新的python虚拟机的一部分。
1.1.13.4. Pyrex
使用Pyrex
直接将Python 应用编译成 C 代码,然后,自然就生成.exe 了
1.2. 体验
手动制作python的exe可执行程序 ~ by LeoJay
1.2.1. PyInstaller
{{{nEO (a.k.a. gentoo.cn) reply-to python-cn@googlegroups.com, to python-cn@googlegroups.com, date Wed,
Apr 2, 2008 at 12:34 AM }}} http://pyinstaller.python-hosting.com/
吸取了py2exe的优点, 支持打包成一个可执行文件, 支持upx壳, 支持多平台 体积比py2exe生成的小 我现在用这个替代py2exe了
1.2.2. NSIS
{{{Gerald Lee reply-to python-cn@googlegroups.com, to python-cn@googlegroups.com, date Tue, Apr 1,
2008 at 8:19 PM subject [CPyUG:45664] Re: 将Python程序转化为可执行程序[整理] }}}
下在编写一个设置的PY文件 setup.py
from distutils.core import setupimport py2exesetup(console=['hello.py'])
运行:python setup.py py2exe 出现以下信息后,在DIST目录里,就会有一个hello.exe 即成功。
running py2exe
*** searching for required modules***
*** parsing results ***
creating python loader for extension 'zlib'
creating python loader for extension 'unicodedata'
creating python loader for extension 'bz2'
*** finding dlls needed ***
*** create binaries ***
*** byte compile python files ***
byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\bz2.py to bz2.pyc
byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\unicodedata.py to unicodedata.pyc
byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\zlib.py to zlib.pyc
skipping byte-compilation of c:\Python24\lib\StringIO.py to StringIO.pyc
[skipping many lines for brevity]
skipping byte-compilation of c:\Python24\lib\warnings.py to warnings.pyc
*** copy extensions ***
*** copy dlls ***
copying c:\Python24\lib\site-packages\py2exe\run.exe -> C:\Tutorial\dist\hello.exe
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them,
andmake sure you don't distribute files belonging to the operating system.
ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
USER32.dll - C:\WINDOWS\system32\USER32.dll
SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll