Code Signing a GUI python App for notarization on macos

I created a python application using py2app and am able to code sign almost all the binaries using the command

Code Block
find "${NAME}.app" -iname '*.so' -or -iname '*.dylib'| while read libfile; do codesign -s "${IDENTITY}" --timestamp -o runtime --entitlements entitlements.plist "${libfile}"; done;


However there are some binaries that are located in a directory in a zip file name.app/Contents/Resouces/lib/python37.zip/PIL/.dylibs

The problem is that these binaries don't get signed because they are located in a zip file. I have tried using Finder to unzip them and zip them back up so that I can code sign those binaries, but unzipping and zipping through Finder causes the program to no longer find the files in the zip.

Code Block
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x000000010bb5ee00 (most recent call first):
Abort trap: 6


Any help would be appreciated.

Answered by DTS Engineer in 675776022

unzipping and zipping through Finder causes the program to no longer
find the files in the zip.

Use unzip -t to print a table of contents for both the original zip archive and the new one you created. It’s likely that there’s some significant difference them, probably related to the root path.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Accepted Answer

unzipping and zipping through Finder causes the program to no longer
find the files in the zip.

Use unzip -t to print a table of contents for both the original zip archive and the new one you created. It’s likely that there’s some significant difference them, probably related to the root path.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Accepted Answer
It was indeed finder zipping the files incorrectly. The root directory was being added to the front of the path for each file which caused the program to not be able to find the paths correctly. I was able to solve this issue by first unzipping the file using finder. Code signing the binaries and then going back into the folder with the unzipped folder "python37" running the command
Code Block
cd python37
zip -r python37.zip ./*

And then moving the zipped folder out of python37 and into lib.

Thanks eskimo for the help, very insightful response.

You are welcome to use these set of utilities

https://github.com/hasii2011/py2appsigner

Code Signing a GUI python App for notarization on macos
 
 
Q