开发者

py2app on Lion is creating empty applications without the python framework or resources

I have a python script which I have successfully packages with py2app prior to upgrading to Lion.

Now when I run py2app it completes without errors, however the resulting .app is only 216K, and when executed it complains about missing objc (which is the first import in the script).

py2app output:

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/b开发者_如何学Cdist.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)

Running the app:

$ ./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

The generated app looks like:

$ 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

It used to look like:

$ 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


Without seeing you setup.py file, my best guess would be that you're not explicitly including the PyObjC library. For example

from setuptools import setup

OPTIONS = {'argv_emulation': False,
           'includes': ['objc'],
          }
setup(
    app='myapp.app',
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

will force py2app to include the objc library. If you're already doing this, it would be helpful to see your setup.py script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜