py2app - convert python scripts into standalone Mac OS X applications

Contents

Abstract

py2app is a Python distutils suite which provides several useful features for distributing Python applications and libraries on the Mac OS X platform. The py2app suite contains the following packages:

py2app:
A distutils command that converts Python scripts into executable Mac OS X applications, able to run without requiring a Python installation. It has been used to create standalone application bundles and plug-ins for open source, commercial, and in-house projects. It is known compatible with GUI frameworks such as wxPython, Tkinter, pygame, PyQt, and PyObjC, but it should work in the context of any framework with little or no effort. It may also be used in conjunction with PyObjC to write plug-ins for Cocoa applications, screen savers, preference panes, etc. This is a complete replacement for the bundlebuilder tool included in the Python standard library.
bdist_mpkg:
Creates Mac OS X installer .mpkg files from Python libraries. Installer packages are familiar to Mac OS X users, provide a safe and easy way to authenticate as root to install privileged files such as headers and scripts. Once a bdist_mpkg distribution has been created, it may be installed to other machines with a similar Python environment without requiring a compiler. Installer packages can be used to do distributed installations with tools such as Apple Remote Desktop or they could be integrated into a custom Mac OS X installation DVD with a tool such as Slipy.
macholib:
Reads and writes the Mach-O object file format. Used by py2app to build a dependency graph of dyld and framework dependencies for your application, and then to copy them into your application and rewrite their load commands to be @executable_path relative. The end result is that your application is going to be completely standalone beyond a default install of Mac OS X. You no longer have to worry about linking all of your dependencies statically, using install_name_tool, etc. It's all taken care of!
modulegraph:
A replacement for the Python standard library modulefinder. Stores the module dependency tree in a graph data structure and allows for advanced filtering and analysis capabilities, such as GraphViz dot output. This is used internally by py2app, but the code should be completely cross-platform. It is hoped that this package will be adopted by application packaging software for other platforms in the future, such as py2exe and cx_Freeze.
altgraph:
This is a fork of Istvan Albert's graphlib, and it used internally by both macholib and modulegraph. It contains several small feature and performance enhancements over the original graphlib.

License

Any components of the py2app suite may be distributed under the MIT or PSF open source licenses.

Downloads

Note that the installer for PyObjC 1.2 ships with py2app 0.1.7.

An installer for py2app 0.1.8 may be downloaded from:

The source to py2app 0.1.8 may be downloaded here:

py2app maintains a public subversion source code repository currently located at:

As of version 0.1.6, py2app uses the extra_path feature of distutils, which changes the installation layout. If you have py2app 0.1.5 or earlier installed, you must manually remove the following directories from your site-packages directory (probably /Library/Python/2.3) if they exist before upgrading:

py2app Documentation

XXX

bdist_mpkg Documentation

XXX

Tools

By default, the following tools are installed to /usr/local/bin:

bdist_mpkg:

A convenient way to run the bdist_mpkg distutils command. Equivalent to editing the setup.py in the current directory to import bdist_mpkg and running the following command:

python setup.py bdist_mpkg --open

If any options are given, then they are given in place of --open.

macho_find:
A tool for finding Mach-O object files using macholib. The arguments may be files or directories. The output of this tool is identical to that of the BSD find command.
macho_standalone:
A tool that makes a valiant attempt to make the given application bundle standalone using macholib using machinery similar, but not identical to, what happens when using py2app. This tool modifies the given application bundle in-place, so you may want to make a backup before performing this operation. This tool works for ANY Mach-O executable bundle, and contains no Python-specific functionality.
py2applet:
A convenient way to run the py2app distutils command without creating a setup.py. The first python script passed as an argument will be the main script, any additional files or directories will be considered as data files. If a file with the .icns extension is passed, it will be used as the application's icon. If a file named Info.plist is given, it will be used as the template for the application's Info.plist. The application will be built with the --argv-emulation on. It is not possible to pass options to py2applet. If you need anything more, you should create a setup.py and use the py2app command in the normal fashion.

GUI Tools

By default, the following GUI tools are installed to /Developer/Applications/Python Tools/py2app:

PackageInstaller:
A droplet version of the bdist_mpkg tool, it does not have any interactivity, so it is not possible to use this tool to pass options other than the default. Errors and informational messages will go to the Console.
py2applet:
A droplet version of the py2applet tool. It works in exactly the same way and provides no interactivity. Note that since you have no guarantee of the order of files in the pasteboard, you should drag only one at a time to this script. Errors and informational messages will go to the console.

Copyright (c) 2004, 2005 Bob Ippolito <bob at redivi.com>.