Code Signing a GUI python App for notarization on macos

536 Views Asked by At

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

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.

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.

1

There are 1 best solutions below

0
On

The issue was that finder was 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

cd python37
zip -r python37.zip ./* 

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

A resource I used to solve this was if anyone needs more information on their own problem: https://askubuntu.com/questions/521011/zip-an-archive-without-including-parent-directory#:~:text=Use%20the%20%2Dj%20or%20%2D%2D,relative%20to%20the%20current%20directory

Could not have solved it without Quinn “The Eskimo!” @ Developer Technical Support @ Apple