2009年8月29日 星期六

Python Compiler (freeze) for Linux

資料來源:http://wiki.python.org/moin/Freeze

安裝套件: apt-get install python2.5-examples
套件路徑: /usr/share/doc/python2.5/examples/Tools/freeze/freeze.py
指令參數: python freeze.py -h

測試編譯: python /path/to/freeze.py [參數] 編譯檔名.py

# python /path/to/freeze.py -o dist test1.py
# cd dist
# make
測試編譯後的linux執行檔
# ./test1

---
錯誤提示:
缺少python2.6/config/config.c.in
安裝以下套件即可
apt-get install python2.6-dev

錯誤提示:
/usr/lib/python2.6/config/libpython2.6.a(posixmodule.o): In function `posix_tmpnam':
(.text+0x783): warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/lib/python2.6/config/libpython2.6.a(posixmodule.o): In function `posix_tempnam':
(.text+0x865): warning: the use of `tempnam' is dangerous, better use `mkstemp'
config.o:(.data+0x98): undefined reference to `init_warnings'
collect2: ld returned 1 exit status
make: *** [client] Error 1

安裝以下套件即可
apt-get install ?????

---
安裝 psyco 加速模組
# wget http://downloads.sourceforge.net/project/psyco/psyco/1.6/psyco-1.6-linux.i386-2.5.tar.gz?use_mirror=nchc
# tar xzvf psyco-1.6-linux.i386-2.5.tar.gz
# cd psyco-1.6
# cp -rf psyco /usr/lib/python2.5/site-packages/

#加入 import psyco
try:
import psyco
psyco.profile()
except:
pass

加入psyco模組,再用freeze作編譯,正常可執行

沒有留言: