1. 程式人生 > 其它 >python 打包總結

python 打包總結

一、配置:

​ python 3.7.4

​ pyinstaller 4.9

二、win打包

pyinstaller -F example.py

exe會自動生成到dist資料夾

三、mac打包

pyinstaller -F example.py

簽名

codesign --entitlements=example.entitlements --deep --force --verbose --timestamp --options=runtime --sign "證書名稱" "要簽名的檔案"
<?xml version="1.0" encoding="utf-8"?>
<plist version="1.0">
<dict>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>

上面的com.apple.security.cs.disable-library-validation千萬不能少,因為pyinstaller會把python打包到可執行檔案,執行時再解壓啟動,所以這裡的python是籤不到名的,所以必須關閉庫驗證