Bill Bumgarner

2004-12-10

PyObjC, py2app, & bundles

PyObjC now has the ability to build NSBundles that can be dynamically loaded by any Objective-C application while the bundle is entirely implemented in Python. In other words, you can now use Python to implement plugins for any app that supports Objective-C plugins (NSBundle).

The PyObjC Subversion repository contains three examples; a screen saver, a preference pane, and an Interface Builder palette.

Most of the innovation comes from py2app. It is used to build the dynamically laodable bits within the NSBundle that then bootstraps the loading of the Python based class implementations.

py2app is also used within the build script of PyObjC. In particular, you can now execute python setup.py bdist_mpkg --open to build an Installer package containing PyObjC, py2app, the examples, and the Xcode templates. Once installed, invoking bdist_mpkg within any Python project that has a setup.py will build an Installer package containing all the bits necessary to install that package.

If you want to build the latest PyObjC, you will need DocUtils. See below.

Bob Ippolito implemented all of the magic. Thanks, Bob -- this stuff is incredible. Awesome stuff. A little over a decade since its inception, PyObjC is still a vibrant project that is growing in exciting new directions while still remaining focused on its core goals.

The pieces involved:

PyObjC bridges Objective-C to Python transparently enough that you can build full featured Cocoa Apps. PyObjC is rapidly approaching a 1.2 release and there are many significant refinements in this release.

py2app builds double-clickable Mac OS X .apps, including all dependencies. Actually, it does considerably more than that. It will also create installer packages from any Python based project that uses distutils (setup.py). py2app can also rewrite mach-o files.

DocUtils is a reStructuredText rendered. reStructuredText is a very simple ASCII format that compiles into nicely formatted HTML, PDF, Open Office, or other kinds of documents.

Comment on this post [ so far] ... more like this: [Mac OS X, PyObjC, Python] ... topic exchange: [Mac OS X, PyObjC, Python]