Skip to content

Instantly share code, notes, and snippets.

@eiberham
Last active October 4, 2020 08:39
Show Gist options
  • Save eiberham/039ae8334cc35d68c8961e35ced0af71 to your computer and use it in GitHub Desktop.
Save eiberham/039ae8334cc35d68c8961e35ced0af71 to your computer and use it in GitHub Desktop.
How to create a mac os x app with python
# first off, install py2app package.
# docs --> https://py2app.readthedocs.io/en/latest/install.html#installing-with-pip
pip3 install -U py2app
# then go to python project's root directory, and run py2applet --make-install command:
py2applet --make-install script.py
# the above command will generate a setup.py file, we must edit it in case we were using
images in our project, we should add them to the DATA_FILES array.
# once done run:
python3 setup.py py2app -A
# the above command will compile your program in "alias" mode, which means your app
# is still not portable to other machines, the idea is to test your app runs ok before
# the real compilation so to speak, the dist and build folders will be created.
# the application lies within the dist folder once tested we can move on to delete the
# dist and build folders and compile the standalone version
rm -rf build dist
python3 setup.py py2app
# that's basically it, the above program will generate a dist folder, now you have
# something that's portable to other machines, to share just compress the dist folder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment