Speno's Pythonic Avocado 14.8.2004

2004-08-14

py2exe and bundlebuilder in use

There's a window's client version of "Project Albatross". Last time I built it using the McMillan Installer. That worked fine, but I didn't like its configuration.

This time around I've decided to use py2exe. I wanted to use it last time too, but there wasn't a Python 2.3 version ready yet. (The last version of "Project Albatross" shipped with Python 2.3alpha2 as its Python interpreter. The new version will use 2.3.4.)

py2exe uses regular distutils stuff, so getting it working was a breeze. I recommend it. Here's my setup.py file for building the Windows client:

from distutils.core import setup import py2exe opts = { "py2exe": { "packages": ["encodings"], "excludes": ["_ssl", "win32api"], "includes": ["msvcr70"], } } setup( windows= [ { "script" : "Albatross.py", "icon_resources" : [ (1, "Albatross.ico")] }, { "script" : "ActiveDirector.py", "dest_base" : "Albatross Assistant", "icon_resources" : [ (1, "Albatross.ico")] }, ], options=opts )

On the Macintosh side, I got myself an old powerbook G3 and installed MacOS X 10.2.8 with Python 2.3.4 and AquaTK 8.4.6. I'm using bundlebuilder to create the application. I'm really glad I wrote that how-to on bundlebuilder in the MacPython FAQ because I got a chance to learn how it works. It's far from perfect, but there's smart people working on making it better. Here's that:

import bundlebuilder # add our SASL_PATH env variable in the startup script SASL_PART = """os.environ['SASL_PATH'] = os.path.join(libdir, 'sasl2')""" lines = bundlebuilder.BOOTSTRAP_SCRIPT.split('\n') lines[-2:-2] = [SASL_PART] bundlebuilder.BOOTSTRAP_SCRIPT = '\n'.join(lines) builder = bundlebuilder.AppBuilder( name='Albatross.app', standalone=1, mainprogram='Main.py', argv_emulation=0, excludeModules=[ 'MacOS', 'Carbon', 'StdSuites', 'aepack', 'aetools', 'aetypes', 'applesingle', 'macresource', 'macurl2path', 'macfs', 'gopherlib', 'ftplib', 'ic', 'icglue', 'ntpath', 'nturl2path', 'uu', ], includeModules=['encodings.__init__', 'encodings.idna', 'encodings.ascii', 'encodings.punycode' ], # should also arrange for libsasl, sasl2/gssapi plugin, and libdl # to be included here. libs = [ '/Library/Frameworks/Tk.Framework', '/Library/Frameworks/Tcl.Framework', ], iconfile='macosx/Albatross.icns' ) builder.setup() builder.build()

As you can see, I had to hack it a bit to get an environmental variable set in the application script. It's ugly, but it works.

Take care.

This post references topics: python
posted at 21:33:52    #    comment []    trackback []
August 2004
MoTuWeThFrSaSu
       1
2 3 4 5 6 7 8
9101112131415
16171819202122
23242526272829
3031     
Jun
2004
 Sep
2004

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

XML-Image Letterimage

© 2004-2005, John P. Speno