Python Py2App在Zip文件中放置PIL Dylibs
我有一个python应用程序,它使用python映像库(PIL),并使用Py2app进行打包。Numpy dylib位于app contents目录中:Python Py2App在Zip文件中放置PIL Dylibs,python,code-signing,py2app,Python,Code Signing,Py2app,我有一个python应用程序,它使用python映像库(PIL),并使用Py2app进行打包。Numpy dylib位于app contents目录中: demo.app/Contents/Resources/lib/python3.8/numpy/.dylibs/libgcc_s.1.dylib 可以在其中搜索和签名,但PIP dylib位于python3.8.zip文件中 demo.app/Contents/Resources/lib/python3.zip -> ./PIL/.d
demo.app/Contents/Resources/lib/python3.8/numpy/.dylibs/libgcc_s.1.dylib
可以在其中搜索和签名,但PIP dylib位于python3.8.zip文件中
demo.app/Contents/Resources/lib/python3.zip -> ./PIL/.dylibs/libfreetype.6.dylib
在那里你必须解压,签名,然后重新解压。为什么会发生这种情况,以及如何防止这种情况发生,以便不必对其进行不同的处理?py2app
通过一种称为。它为某些包提供了内置的配方,包括numpy
,这就是为什么numpy被排除在.zip
文件之外的原因。()
除了内置的配方之外,您还可以为py2app使用。只需定义一个具有check
方法的类,并将其作为属性添加到py2app.recipes
:
setup.py中的#
类PIL_配方:
def检查(自检、cmd、mf):
m=mf.findNode(“PIL”)
如果m为None或m.filename为None:
一无所获
#从site-packages.zip中排除
返回{“packages”:[“PIL”]}
py2app.recipes.PIL=PIL_recipe()
...
设置(…)
如果需要对多个库执行此操作,则可以推广此技巧,使其不会硬编码包的名称:
class ExcludeFromZip_Recipe(object):
def __init__(self, module):
self.module = module
def check(self, cmd, mf):
m = mf.findNode(self.module)
if m is None:
return None
# Don't put the module in the site-packages.zip file
return {"packages": [self.module]}
for module in ['PIL', 'skimage', 'sklearn', 'jsonschema']:
setattr( py2app.recipes, module, ExcludeFromZip_Recipe(module) )
免责声明:这就是我过去解决这个问题的方法。但是我不确定为什么您的zip文件名为python3.zip
,而不是site packages.zip