Skip to content

Instantly share code, notes, and snippets.

@HuangJiaLian
Created April 2, 2022 05:37
Show Gist options
  • Save HuangJiaLian/57ebb0a8ed8b73305f32c792dd43b834 to your computer and use it in GitHub Desktop.
Save HuangJiaLian/57ebb0a8ed8b73305f32c792dd43b834 to your computer and use it in GitHub Desktop.
Two steps to turn a Python file to a macOS installer
#!/bin/sh
# Ref.: https://www.pythonguis.com/tutorials/packaging-pyqt5-applications-pyinstaller-macos-dmg/
rm -rf build dist/*
#################################################
# Create app file using pyinstaller
#################################################
pyinstaller --name 'Huanbu' \
--icon 'huanbu.ico' \
--windowed \
--add-data='./strong_beat.wav:.' \
--add-data='./sub_strong_beat.wav:.' \
--add-data='./weak_beat.wav:.' \
huanbu.py
#################################################
# Build the application bundle into a disk image
#################################################
# Create a folder (named dmg) to prepare our DMG in
# (if it doesn't already exist).
mkdir -p dist/dmg
# Empty the dmg folder.
rm -rf dist/dmg/*
# Copy the app bundle to the dmg folder.
cp -r "dist/Huanbu.app" dist/dmg
# If the DMG already exists, delete it.
test -f "dist/Huanbu.dmg" && rm "dist/Huanbu.dmg"
create-dmg \
--volname "Huanbu" \
--volicon "huanbu.ico" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--icon "Huanbu.app" 175 120 \
--hide-extension "Huanbu.app" \
--app-drop-link 425 120 \
"dist/Huanbu.dmg" \
"dist/dmg/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment