### setup.cfg option example: includes Source: https://py2app.readthedocs.io/en/latest/options.html Shows how to specify py2app options in a setup.cfg file. Both hyphens and underscores are accepted in setup.cfg. ```ini [py2app] includes=os,platform ``` -------------------------------- ### include_plugins option example Source: https://py2app.readthedocs.io/en/latest/changelog.html Shows how to configure the include_plugins option in a py2app setup script. The value is a list of paths or tuples with plugin type and path. Supported plugin suffixes include .qlgenerator, .mdimporter, .xpc, .service, .prefPane, .iaplugin, and .action. ```python include_plugins=[ "MyPlugins/MyDocument.qlgenerator", ("SystemConfiguration", "MyPlugins/MyConfig.plugin"), ] ``` -------------------------------- ### Start application with LaunchServices using open Source: https://py2app.readthedocs.io/en/latest/tutorial.html Launch the application normally with LaunchServices. Additional arguments simulate 'open document' events. ```bash $ open -a dist/MyApplication.app ``` -------------------------------- ### setup.py option example: includes Source: https://py2app.readthedocs.io/en/latest/options.html Shows how to specify py2app options in a setup.py file using the options dict. Note that hyphens in command-line options become underscores in setup.py. ```python setup( app=['MyApplication.py'], options=dict(py2app=dict( includes=["os", "platform"] )), ) ``` -------------------------------- ### Configure LSEnvironment in py2app setup() Source: https://py2app.readthedocs.io/en/latest/environment.html Use this setup() call to inject custom environment variables into the launched application via the LSEnvironment key in Info.plist. The example sets LANG, LC_CTYPE, EXTRA_VAR, and KNIGHT. This is an alternative to the emulate_shell_environment option. ```python setup( name='BasicApp', app=['main.py'], options=dict(py2app=dict( plist=dict( LSEnvironment=dict( LANG='nl_NL.latin1', LC_CTYPE='nl_NL.UTF-8', EXTRA_VAR='hello world', KNIGHT='ni!', ) ) )), ) ``` -------------------------------- ### Install py2app from source Source: https://py2app.readthedocs.io/en/latest/install.html Install py2app from source using the standard Python package installation procedure. Dependencies are automatically acquired and installed via setuptools. ```bash $ python setup.py install ``` -------------------------------- ### Specify required Python distributions with install_requires in setup() Source: https://py2app.readthedocs.io/en/latest/changelog.html Use the install_requires argument in the setup() function to specify which Python distributions must be available when building the bundle. The example shows requiring 'pyobjc == 2.2'. ```python setup( ... install_requires = [ "pyobjc == 2.2" ], ) ``` -------------------------------- ### Command-line option example: --includes Source: https://py2app.readthedocs.io/en/latest/options.html Shows how to pass py2app options on the command line, using --includes to include the 'os' and 'platform' modules. ```bash $ python setup.py py2app --includes=os,platform ``` -------------------------------- ### New setup.py template (py2app 0.3) Source: https://py2app.readthedocs.io/en/latest/install.html The updated setup.py script for py2app 0.3, using setuptools and specifying setup_requires to automatically acquire py2app during setup. ```python from setuptools import setup setup( app=["myscript.py"], setup_requires=["py2app"], ) ``` -------------------------------- ### Specify Info.plist customizations via XML file in setup.py Source: https://py2app.readthedocs.io/en/latest/tweaking.html Use the --plist option or the 'plist' key in the py2app options dict to specify an Info.plist XML file. This example shows the setup.py configuration. ```python setup( app=['MyApplication.py'], options=dict(py2app=dict( plist='Info.plist', )), ) ``` -------------------------------- ### Install py2app with pip Source: https://py2app.readthedocs.io/en/latest/install.html Use pip3 to install or upgrade py2app to the latest released version. ```bash $ pip3 install -U py2app ``` -------------------------------- ### Specify Info.plist customizations via Python dict in setup.py Source: https://py2app.readthedocs.io/en/latest/tweaking.html Alternatively, provide the plist as a Python dict in the setup.py. This example sets the LSPrefersPPC key to True. ```python setup( app=['MyApplication.py'], options=dict(py2app=dict( plist=dict( LSPrefersPPC=True, ), )), ) ``` -------------------------------- ### Inspect symlinked library with ls and otool Source: https://py2app.readthedocs.io/en/latest/changelog.html Shows how to inspect a symlinked library in /opt/homebrew/lib. The first command lists the symlink, the second shows the install name. This example illustrates the symlink issue fixed in Issue #88. ```shell $ ls -l /opt/homebrew/lib ... libglib-2.0.0.dylib -> ../Cellar/glib/2.32.4/lib/libglib-2.0.0.dylib ... $ otool -vL /opt/homebrew/lib/libglib-2.0.0.dylib /opt/homebrew/lib/libglib-2.0.0.dylib: /opt/homebrew/lib/libglib-2.0.0.dylib (compatibility version 3201.0.0, current version 3201.4.0) time stamp 1 Thu Jan 1 01:00:01 1970 ... ``` -------------------------------- ### pyEnchant recipe note Source: https://py2app.readthedocs.io/en/latest/changelog.html A note explaining that the pyEnchant recipe only works for installations where pyEnchant is stored in the installation (such as binary eggs on PyPI), not for installations using the PYENCHANT_LIBRARY_PATH environment variable or MacPorts. ```text The recipe only works for installations of pyEnchant where pyEnchant is stored in the installation (such as the binary eggs on PyPI), not for installations that either use the "PYENCHANT_LIBRARY_PATH" environment variable or MacPorts. ``` -------------------------------- ### Create setup.py with py2applet Source: https://py2app.readthedocs.io/en/latest/tutorial.html Run py2applet to generate a setup.py file for your script. Specify icon (.icns) and data files as additional arguments if needed. ```bash $ py2applet --make-setup MyApplication.py Wrote setup.py ``` -------------------------------- ### Clean build and dist directories Source: https://py2app.readthedocs.io/en/latest/tutorial.html Remove build and dist folders before starting development or switching development modes. ```bash $ rm -rf build dist ``` -------------------------------- ### Basic py2app setup.py template Source: https://py2app.readthedocs.io/en/latest/examples.html Minimal setup.py script for building a py2app application. It uses setuptools and specifies the app entry point. The py2applet script can generate this file automatically with the command 'py2applet --make-setup MyApplication.py'. ```python """ py2app build script for MyApplication Usage: python setup.py py2app """ from setuptools import setup setup( app=["MyApplication.py"], setup_requires=["py2app"], ) ``` ```bash $ py2applet --make-setup MyApplication.py ``` -------------------------------- ### Define a py2app.converter entry point in setup.py Source: https://py2app.readthedocs.io/en/latest/changelog.html Shows how to register a data converter plugin by adding an entry point in the 'py2app.converter' group. The entry point maps a label to a converter function. ```python setup( ... entry_points = { 'py2app.converter': [ "label = some_module:converter_function", ] }, ... ) ``` -------------------------------- ### Set PyRuntimeLocations in plist Source: https://py2app.readthedocs.io/en/latest/changelog.html Workaround for PyRuntimeLocations issues on machines with /Library/Frameworks/Python.framework installed. Set this key in your plist to resolve the problem. ```python PyRuntimeLocations=['/System/Library/Frameworks/Python.framework/Versions/2.3/Python'] ``` -------------------------------- ### Command to list py2app options: --help Source: https://py2app.readthedocs.io/en/latest/options.html Use this command to enumerate all supported py2app options. ```bash $ python setup.py py2app --help ```