4
我有一個python腳本,在升級到Lion之前,我已經用py2app成功打包了這個腳本。Lion上的py2app正在創建沒有python框架或資源的空應用程序
現在,當我運行py2app它完成沒有錯誤,但是結果.app只有216K,並且執行時它抱怨缺少objc(這是腳本中的第一個導入)。
py2app輸出:
running py2app
creating /Users/byron/Dropbox/dev/Hours-Worked/build
creating /Users/byron/Dropbox/dev/Hours-Worked/build/bdist.macosx-10.7-intel
creating /Users/byron/Dropbox/dev/Hours-Worked/build/bdist.macosx-10.7-intel/python2.7-semi_standalone
creating /Users/byron/Dropbox/dev/Hours-Worked/build/bdist.macosx-10.7-intel/python2.7-semi_standalone/app
creating /Users/byron/Dropbox/dev/Hours-Worked/build/bdist.macosx-10.7-intel/python2.7-semi_standalone/app/collect
creating /Users/byron/Dropbox/dev/Hours-Worked/build/bdist.macosx-10.7-intel/python2.7-semi_standalone/app/temp
creating /Users/byron/Dropbox/dev/Hours-Worked/dist
creating build/bdist.macosx-10.7-intel/python2.7-semi_standalone/app/lib-dynload
creating build/bdist.macosx-10.7-intel/python2.7-semi_standalone/app/Frameworks
*** using recipe: virtualenv ***
*** filtering dependencies ***
376 total
372 filtered
0 orphaned
4 remaining
*** create binaries ***
*** byte compile python files ***
byte-compiling /Library/Python/2.7/site-packages/py2app-0.6.3-py2.7.egg/py2app/bootstrap/boot_app.py to boot_app.pyc
byte-compiling /Library/Python/2.7/site-packages/py2app-0.6.3-py2.7.egg/py2app/bootstrap/chdir_resource.py to chdir_resource.pyc
byte-compiling /Library/Python/2.7/site-packages/py2app-0.6.3-py2.7.egg/py2app/bootstrap/disable_linecache.py to disable_linecache.pyc
byte-compiling /Users/byron/Dropbox/dev/Hours-Worked/hours-worked.py to hours-worked.pyc
*** creating application bundle: Hours-Worked ***
copying hours-worked.py -> /Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources
creating /Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources/lib
creating /Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources/lib/python2.7
copying build/bdist.macosx-10.7-intel/python2.7-semi_standalone/app/site-packages.zip -> /Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources/lib/python2.7
creating /Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources/lib/python2.7/lib-dynload
creating /Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Frameworks
stripping Hours-Worked
stripping saved 15936 bytes (71424/87360)
運行的應用程序:
$ ./dist/Hours-Worked.app/Contents/MacOS/Hours-Worked
Traceback (most recent call last):
File "/Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources/__boot__.py", line 31, in <module>
_run('hours-worked.py')
File "/Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources/__boot__.py", line 28, in _run
execfile(path, globals(), globals())
File "/Users/byron/Dropbox/dev/Hours-Worked/dist/Hours-Worked.app/Contents/Resources/hours-worked.py", line 3, in <module>
import objc
ImportError: No module named objc
2011-08-09 15:27:40.306 Hours-Worked[16825:707] Hours-Worked Error
生成的應用程序是這樣的:
$ du -hs dist/Hours-Worked.app/Contents/*
0B dist/Hours-Worked.app/Contents/Frameworks
4.0K dist/Hours-Worked.app/Contents/Info.plist
76K dist/Hours-Worked.app/Contents/MacOS
4.0K dist/Hours-Worked.app/Contents/PkgInfo
132K dist/Hours-Worked.app/Contents/Resources
它曾經的樣子:
$ du -hs Hours-Worked.app/Contents/*
4.0M Hours-Worked.app/Contents/Frameworks
4.0K Hours-Worked.app/Contents/Info.plist
188K Hours-Worked.app/Contents/MacOS
4.0K Hours-Worked.app/Contents/PkgInfo
12M Hours-Worked.app/Contents/Resources
顯式包含PyObjC並不是必需的,py2app會檢測到該庫已被使用並自動包含它。 –