How to create macOS application bundles with Python

less than 1 minute read

Published:

Creating macOS application bundles that appear on your launchpad and can be docked is extremely easy. Once you have finished coding your Python script, change the .py prefix to .command and make it executable:

chmod +x your_script.command

Create a Mac application bundle:

cd /Applications
mkdir -p your_app.app/Contents/MacOS
echo -e '#!/bin/bash'"\n your_python_executable_path $@" >> your_app.app/Contents/MacOS/your_app
chmod +x your_app.app/Contents/MacOS/your_app

Create a file named Info.plist in the Contents folder (at your_app.app/Contents/Info.plist) with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleExecutable</key>
<string>your_app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>1.0.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
</dict>
</plist>

Download the your logo. Click on the your_app in Application folder, and press command+i. This will bring up the info. Open the icon image and press control+c, and then copy it to the logo by clicking the icon on top left corner and press control+v.

This way, we have created an macOS app! There are many Python GUI frameworks like: PyQT, WxPython etc. Those powerful frameworks enable macOS app developments with Python.

Thank you for reading!