Speno's Pythonic Avocado 16.1.2004

2004-01-16

Building MacOS X applications with Python

Update: This tutorial was expanded again and posted here .

This is a cheap entry since I just added this answer to the MacPython FAQ on how to build a stand-alone MacOS X application using Python.

This can be very easy to build using bundlebuilder.py.

First create your app building script like so:

from bundlebuilder import buildapp buildapp( name='Application.app', # what to build mainprogram='main.py', # your app's main() argv_emulation=1, # drag&dropped filenames show up in sys.argv iconfile='myapp.icns', # file containing your app's icons standalone=1, # make this app self contained. includeModules=[], # list of additional Modules to force in includePackages=[], # list of additional Packages to force in )

Besides building a stand-alone application which will bundle up everything you need to run your application including the Python.Framework, you can build using 'semi-standalone=1' instead. This will make your application bundle smaller as it won't include python, but it does require that your users already have a working python framework installed. On MacOS X 10.3, Apple has included a full 2.3 Python.Framework for you which will work with semi-standalone applications just fine.

There are other options you can set in the call to buildapp(). See the bundlebuilder.py module for the rest of them.

Then do this:

% python makeapplication.py build

That command should create a build/Application.app bundle, which may even work, but probably needs a little help. There will most likely be a few warnings. These can usually be ignored safely. Also, there may be additional modules and libraries which need to be included that buildapp() couldn't determine. You can add those it missed using the includeModules and includePacakges arguments to buildapp().

For example, if your application used Tkinter, you may need to copy Tcl.Framework and Tk.Framework into build/Application.app/Contents/Frameworks. You can use those from the standalone AquaTcl/TK package (i.e. the Wish.app/Contents/Frameworks/*).

Take care.

This post references topics: python
posted at 20:59:28    #    comment []    trackback []
January 2004
MoTuWeThFrSaSu
    1 2 3 4
5 6 7 8 91011
12131415161718
19202122232425
262728293031 
Dec
2003
 Feb
2004

One python programmer's search for understanding and avocados. This isn't personal, only pythonic.

XML-Image Letterimage

© 2004-2005, John P. Speno