Projects http://cx-freeze.sourceforge.net/
# wget cx_Freeze-4.1.tar.gz
# tar xzvf cx_Freeze-4.1.tar.gz
# cd cx_Freeze-4.1
記得看一下說明檔!!
# cat README.txt
------------
Please see cx_Freeze.html for documentation on how to use cx_Freeze.
To build:
python setup.py build
python setup.py install
On Windows I have used the MinGW compiler (http://www.mingw.org)
python setup.py build --compiler=mingw32
python setup.py build --compiler=mingw32 install
------------
安裝
# python setup.py build
# python setup.py install
參考一下範例 samples/
[advanced] [matplotlib] [relimport] [simple] [wx]
測試-先來個簡單的
# cd samples/simple
# ls 看一下有什麼東西
hello.py setup.py 只有二個檔案,內容都很容易懂的
setup.py 內容
------------
# A very simple setup script to create a single executable
#
# hello.py is a very simple "Hello, world" type script which also displays the
# environment in which the script runs
#
# Run the build process by running the command 'python setup.py build'
#
# If everything works well you should find a subdirectory in the build
# subdirectory that contains the files needed to run the script without Python
from cx_Freeze import setup, Executable
setup(
name = "hello",
version = "0.1",
description = "Sample cx_Freeze script",
executables = [Executable("hello.py")])
------------
測試編譯
# python setup.py build
# ls 看一下多出什麼東西
[build] hello.py setup.py 多出一個 build的目錄
# cd build/
# ls
[exe.linux-x86_64-2.5] 這個目錄的名稱會依使用的核心作命名
# cd exe.linux-x86_64-2.5
# ls -l
-rw-r--r-- 1 root root 41416 2009-08-29 12:34 array.so
-rwxr-xr-x 1 root root 11888 2009-08-29 12:34 hello 編譯好的檔案
-rw-r--r-- 1 root root 42112 2009-08-29 12:34 itertools.so
-rw-r--r-- 1 root root 1473760 2009-08-29 12:34 libpython2.5.so.1.0
-rw-r--r-- 1 root root 74373 2009-08-29 12:34 library.zip
-rw-r--r-- 1 root root 23352 2009-08-29 12:34 zlib.so
ps. 除了hello是剛才測試後的執行檔,其它的都是必須的不能刪除
ps. 記得如果要拷貝到其它地方執行,其它的檔案都要拷貝才能正確執行
# ./hello 測試編譯好的檔案是否有正常執行
ps. 範例中的項目最好都去看一下setup.py
例. [relimport] setup.py 一看就明白,自制模組要如何放置
沒有留言:
張貼留言