如何为 Catalina 发行版编写从 Pyinstaller 创建的应用程序

jl3*_*303 5 python macos pyinstaller codesign macos-catalina

我在公证和分发从 pyinstaller 打包到 Catalina 的应用程序时遇到问题。

在我的 entitlements.plist 中,我将 com.apple.security.cs.allow-jit 和 com.apple.security.cs.allow-unsigned-executable-memory 设置为 true。

我还尝试设置 com.apple.security.cs.disable-library-validation。但是,如果我这样做,我什至无法打开它。它只是要求我把它扔掉。

这是我的代码签名命令。

codesign --deep --force --options runtime --entitlements entitlements.plist --sign "$DEVELOPER" "$APP.app" --timestamp

当我打开时,我得到了这个。

[1276] Error loading Python lib '/var/folders/kb/ww5w7w_s45139t2n329cr3lw0000gn/T/_MEI3Jv8Ln/libpython3.7m.dylib': dlopen: dlopen(/var/folders/kb/ww5w7w_s45139t2n329cr3lw0000gn/T/_MEI3Jv8Ln/libpython3.7m.dylib, 10): no suitable image found.  Did find:
    /var/folders/kb/ww5w7w_s45139t2n329cr3lw0000gn/T/_MEI3Jv8Ln/libpython3.7m.dylib: code signature in (/var/folders/kb/ww5w7w_s45139t2n329cr3lw0000gn/T/_MEI3Jv8Ln/libpython3.7m.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
    /var/folders/kb/ww5w7w_s45139t2n329cr3lw0000gn/T/_MEI3Jv8Ln/libpython3.7m.dylib: stat() failed with errno=3
Run Code Online (Sandbox Code Playgroud)

codesign -f -s "$DEVELOPER" /path/to/libpython3.7m.dylib在运行 pyinstaller 之前也尝试过,但是当我在 Catalina 机器上运行该应用程序时,我得到了“Killed: 9”。

如果我不协同设计并强制允许从系统首选项> 安全性运行,它就可以正常工作。

我希望能够正常分发而无需用户这样做。