Building Mac OS X applications with py2app
sudo easy_install py2app
python setup.py py2appAfter which in dist folder you will have ready to used app. You can (should) edit it's name editing App content ("Show package contents") in Contents/Info.plist, and using custom icon (Contents/Resources/PythonApplet.icns). Check also if the app doesn't contain unnecessary Python modules. If it does use excludes list in OPTIONS to exclude them.
Using system Python installation py2app will create semi-standalone apps, that will probably not work on other OS X releases (app build on Leopart may not run on Tiger for example). To build fully standalone apps use external Python installation from MacPorts or Fink. To build app against such Python install be sure to use full path to that Python executable file (for example: /sw/bin/python setup.py py2app)
Qt Software offers two DMGs - SDK and Libraries. If you want Intel only app download the SDK DMG. If you use "Libraries"-only DMG you will get double sized app, but universal.
Here is a simple config for a PyQt4 app that uses QtCore, QtGui and simplejson: We have to exclude all other components or they will be included in the app (which will make it big as hell). The app won't work out of the box in this case. You will get:
python configure.py make # if the compilation doesn't start sudo make install
You have to edit Contents/Resources/__boot__.py and add in function def _run(*scripts): (near end of file) and add after imports this line:
ImportError: '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/PyQt4/QtCore.so' not found
sys.path = [os.path.join(os.environ['RESOURCEPATH'], 'lib', 'python2.5', 'lib-dynload')] + sys.pathAnd it should work now. You can also remove from Contents/Frameworks/* all *_debug versions of QtCore and QtGui as they aren't used, and they are bigger files. Those libs are placed in "Versions" subfolders, for example /Contents/Frameworks/QtGui.framework/Versions/4. After zipping my app had 12MB (9MB on Windows when built with Py2exe).
In case of MacPorts it's easier, but compiling everything will take some time (you need at least PyQt4, py2app, macholib, modulegraph, altgraph). Py2app config is nearly the same, you only add PyQt4._qt (but it may be bigger than build against system Python): You can find more on Aral Balkan blog.