This is a barebones Python app that can be submitted to the Mac App Store.
It displays a simple dialog and exits.
- OS X 10.8 (Mountain Lion)
- Other OS X versions from 10.6+ will probably work.
- Python 2.7.x
- This exact version of Python is required because the build process has patching steps specific to
lib/python2.7
.
- This exact version of Python is required because the build process has patching steps specific to
- py2app 0.8.1 or later
- Really old versions of py2app create invalid
Python.framework
bundles in generated apps that won't pass Mac App Store checks.
- Really old versions of py2app create invalid
- (Optional) wx 3.0.0.0 osx-cocoa (classic)
- (Optional) PySide 1.1.1 / QT 4.8.6
- (Optional) PtQt 4.11 / sip 4.16.1 / QT 4.8.6
- Clone this repository or download a ZIP file of it:
git clone https://github.com/davidfstr/Python-in-Mac-App-Store.git
cd Python-in-Mac-App-Store
- Build the app package
dist/HelloAppStore.app
:./build-app.sh
- Build the installer package
dist/HelloAppStore.pkg
:./build-pkg.sh
For submission to the App Store you will also need to enable code signing:
- Configure code signing:
- Update the
SIGNING_IDENTITY
line incode-signing-config.sh
to refer to your Mac App Store signing certificates:- You will need an Apple Developer account and a subscription to the Mac Developer Program ($99/year) to get signing certificates.
- Create the appropriate Mac App Store certificates in the Mac Dev Center and download them to your dev machine.
- Change the
DO_CODE_SIGNING
line incode-signing-config.sh
to assign1
instead of0
.
- Update the
- Rebuild the app package and installer package using the same steps as above.
- Create a record for your app inside iTunes Connect.
- Create a unique bundle identifier for your app record and update the
CFBundleIdentifier
key insrc/Info.plist
to match it. - Fill out app metadata, including its description, keywords, screenshots, etc.
- Press "Ready to Upload Binary".
- Create a unique bundle identifier for your app record and update the
- Open Application Loader:
- Open Xcode.
- From the menubar, select Xcode > Open Developer Tool > Application Loader.
- Click "Deliver Your App" and select the app record you created in iTunes Connect.
- When you are prompted for an item to upload, select
dist/HelloAppStore.pkg
.
Any app you submit to the Mac App Store must have a GUI. In Python there are a few libraries available to create a GUI:
- Tkinter / Tk - Built-in to Python. Just works.
- Poorly documented. Limited widget set.
- Overhead: Nothing
- PyObjC / Cocoa - Full bindings to the Cocoa frameworks.
- Reasonably documented and maintained. (But requires you to learn Cocoa.)
- Provides full access to all OS X native widgets.
- Overhead: Nothing
- ctypes / Cocoa - Low-level bindings directly to Cocoa frameworks.
- Most direct way to access native Cocoa frameworks, albeit verbose.
- Almost no online documentation for this approach.
- The cocoa-python library exposes a tiny subset of Cocoa using ctypes. Reading its source code is illustrative.
- Overhead: Nothing
- wxPython / wxWidgets
- Well documented. Lots of widgets.
- Note: Cannot be submitted to Mac App Store due to wxPython's reliance on deprecated QuickTime APIs.
- Overhead: 38.7 MB uncompressed, 13.3 MB compressed
- PySide / QT
- Well documented. Unsure if maintained.
- Note: The app created by py2app crashes with a segmentation fault. My guess is that the py2app needs a special "recipe" for PySide. I don't feel like writing one myself.
- Overhead: 16.6 MB uncompressed, 6.3 MB compressed (estimated)
- PyQt4 / QT
- Note: I am unable to build from source and no binary installers for OS X are available. Seriously don't people test anything these days?
The above assessment leaves the following choices for Mac App Store apps:
- Tkinter
- PyObjC
- ctypes
Probably PyObjC is the best choice to get full functionality. I'm disappointed that wxPython gets the shaft here, as most of my preexisting GUI apps in Python are written with wxPython.
This example app uses Tkinter by default but includes samples for several of the other GUI libraries.
If you'd like to try the other samples, open src/HelloAppStore.py
and change the main
function to call one of the other libraries.