py2app

suggest change

py2app builds macOS application bundles. To use it you must install it first. easy_install is no longer provided by current setuptools. The command below is the old installer:

sudo easy_install -U py2app

You can also install it with pip:

pip install py2app

Then create the setup file for your python script:

py2applet --make-setup MyApplication.py

Edit the settings of the setup file to your liking. The file below is shown as the default, but its APP entry is test.py while the command above names MyApplication.py. This was not run:

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['test.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

To add an icon file (this file must have a .icns extension), or include images in your application as reference, change your options as shown:

DATA_FILES = ['myInsertedImage.jpg']
OPTIONS = {'argv_emulation': True, 'iconfile': 'myCoolIcon.icns'}

Finally enter this into terminal:

python setup.py py2app

The script should run and you will find your finished application in the dist folder.

Use the following options for more customization:

optimize (-O)         optimization level: -O1 for "python -O", -O2 for
                      "python -OO", and -O0 to disable [default: -O0]

includes (-i)         comma-separated list of modules to include

packages (-p)         comma-separated list of packages to include

extension             Bundle extension [default:.app for app, .plugin for
                      plugin]

extra-scripts         comma-separated list of additional scripts to include
                      in an application or plugin.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents