Notarize a MacOS Python Qt App

Notarize a MacOS Python Qt App
Introduction
In this guide, we’ll demonstrate how to notarize a Python Qt application to Apple using PyInstaller. We’ll cover the steps from packaging and signing the app, archiving and ultimately Notarization.
Prerequisites
- Apple Developer Account
Step 1: Prepare Your Python Environment
To packet a python app that support MacOS’s Universal 2, you need make sure both python and python QT support Universal 2. I use:
- Python from https://www.python.org/ It supports Universal 2
- PySide6 (PYQT6 will return error when packeting app)
Step 2: PyInstaller’s spec file
You need to have a spec file to tell PyInstaller how to pack the app. Here is an example:
1 | a = Analysis( |
Step 3: Pack the python files using PyInstaller
1 | /usr/local/bin/python3 -m PyInstaller ./app.spec |
Step 4: Sign the app
You need use the “Developer ID Application” to sign the app. Here is the command:
1 | codesign --force --timestamp --options=runtime --sign "Developer ID Application: XXXXXX LLC (123456789)" "./App.app" |
Step 5: Archive the App
1 | ditto -c -k --keepParent "App.app" ./app.zip |
Step 6: Submit to Apple using Apple ID and app-specific password:
xcrun altool --notarize-app --primary-bundle-id "com.xxxx.xxxx" --username "username@gmail.com" --password "aaaa-bbbb-cccc-dddd" --file ./app.zip
Step 7: Wait Apple for review
Step 8: After Apple approve the App, attach the staple to the App:
1 | xcrun stapler staple "App.app" |
- Title: Notarize a MacOS Python Qt App
- Author: wasdwasd0105
- Created at : 2023-11-23 20:35:27
- Updated at : 2023-11-25 22:44:39
- Link: https://wasdwasd0105.github.io/2023/11/23/Notarize-a-MacOS-Python-Qt-App/
- License: This work is licensed under CC BY-NC-SA 4.0.
Other Articles