1

安装程序.py

APP = ['systray.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,
           'includes': ['djmemori.settings'],
           'packages': ['django', 'south'],
           'qt_plugins': 'imageformats' # if I comment out this line, python setup.py py2app will success
           }

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

python setup.py py2app

...
copying file /Users/teamx/workspace/env-memori-pkg/lib/python2.7/site-packages/py2app/recipes/qt.conf -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt.conf
copying file /Developer/Applications/Qt/plugins/imageformats/libqgif.dylib -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt_plugins/imageformats/libqgif.dylib
copying file /Developer/Applications/Qt/plugins/imageformats/libqico.dylib -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt_plugins/imageformats/libqico.dylib
copying file /Developer/Applications/Qt/plugins/imageformats/libqjpeg.dylib -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt_plugins/imageformats/libqjpeg.dylib
copying file /Developer/Applications/Qt/plugins/imageformats/libqmng.dylib -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt_plugins/imageformats/libqmng.dylib
copying file /Developer/Applications/Qt/plugins/imageformats/libqsvg.dylib -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt_plugins/imageformats/libqsvg.dylib
copying file /Developer/Applications/Qt/plugins/imageformats/libqtiff.dylib -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt_plugins/imageformats/libqtiff.dylib
copying file /.dbfseventsd -> /Users/teamx/workspace/memori_pc/src/djmemori/dist/systray.app/Contents/Resources/qt_plugins/imageformats/.dbfseventsd
error: /.dbfseventsd: Operation not supported on socket
4

2 回答 2

1

更改代码 py2app/recipes/pyside.py:21

    if '*' in item:
        for path in glob.glob(os.path.join(plugin_dir, item)):
            resources.append((os.path.dirname('qt_plugins' + path[len(plugin_dir):]), [path]))
        else:
            resources.append((os.path.dirname(os.path.join('qt_plugins', item)), os.path.join(plugin_dir, item)))

    if '*' in item:
        for path in glob.glob(os.path.join(plugin_dir, item)):
            resources.append((os.path.dirname('qt_plugins' + path[len(plugin_dir):]), [path]))
    else:
        resources.append((os.path.dirname(os.path.join('qt_plugins', item)), os.path.join(plugin_dir, item)))

可以解决这个问题。

代码缩进问题会导致py2app添加资源:

('qt_plugins/imageformats', u'/Developer/Applications/Qt/plugins/imageformats/*') # 注意元组的第二项应该是列表,但这里是字符串

然后在 py2app/build_app.py:598

def iter_data_files(self):
    dist = self.distribution
    allres = chain(getattr(dist, 'data_files', ()) or (), self.resources)
    for (path, files) in (normalize_data_file(fn) for fn in allres):
        path = fsencoding(path)
        for fn in files:                      # <-- this line
            fn = fsencoding(fn)
            yield fn, os.path.join(path, os.path.basename(fn))

files 应该是一个列表,但现在,它是一个字符串:u'/Developer/Applications/Qt/plugins/imageformats/*' 这将导致 py2app 复制路径中的文件:'/'、'D'、'e'、 'v', ...所以py2app开始迭代根路径'/',当它遇到/.dbfseventsd时,它崩溃了。

于 2013-03-01T07:41:20.860 回答
0

这看起来像 py2app 中的一个错误。您能否帮我检查一下“/Developer/Applications/Qt/plugins/imageformats”中是否有一个名为“.dbfseventsd”的文件(或指向该文件的符号链接)?

另外,请在https://bitbucket.org/ronaldoussoren/py2app提出问题,以确保我不会忘记实际解决问题。

于 2013-02-27T10:22:06.263 回答