py2app на Lion создает пустые приложения без фреймворка или ресурсов python - PullRequest
4 голосов
/ 09 августа 2011

У меня есть скрипт на python, который я успешно упаковал с py2app до обновления до Lion.

Теперь, когда я запускаю 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

1 Ответ

0 голосов
/ 09 января 2012

Не видя ваш файл setup.py, я думаю, что вы явно не включаете библиотеку PyObjC. Например

from setuptools import setup

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

заставит py2app включить библиотеку objc. Если вы уже делаете это, было бы полезно увидеть ваш скрипт setup.py.

...