[Pythonmac-SIG] talkingpanda installer - PyObjC experience

Bob Ippolito bob at redivi.com
Mon Jun 28 12:18:25 EDT 2004


I'll only plug this once, but one of the things I've been working on 
for a while now is talking panda ( http://talkingpanda.com/ ), a set of 
foreign language phrase books for the version 2 and later firmware 
iPods (anything with buttons above the wheel, including the Mini).  
There's a flash demonstration and an iPod-installable Japanese demo up 
on the site (see the right sidebar) if you want to play before you pay 
:)

The installer is written in about 95% PyObjC, with the rest in ObjC and 
C.  I used the Xcode template to develop it.  I did not use Cocoa 
Bindings as I wanted OS X 10.2 support.  I had to do several things in 
PyObjC that I had not done before, such as creating a NSMatrix 
subclass, and doing AppleEvents asynchronously (via the low level 
interface of an unreleased copy of aeve I have).

For OS X 10.2 support, I did it all by hand.  I had my working 
application for 10.3, then I had it print all of the keys and values 
from sys.modules where the value had a sensible __file__.  I then went 
to an OS X 10.2 machine and installed Python (from the MacPython page) 
and compiled the relevant packages (PyObjC, LaunchServices, 
TECManager).  I then used this dependency list to strip down the 
framework to the bare essentials, and I used:
find . -name "*.so" -exec install_name_tool -change 
/Library/Frameworks/Python.framework/Versions/2.3/Python 
@executable_path/../Frameworks/Python.framework/Versions/2.3/Python {} 
\;

to rewrite the mach-o load commands (as well as install_name_tool -id 
@exec... on the Python dylib, of course).

then I brought this all into my Xcode project and made a copy files 
build phase for the framework.  I had to change main.m to inject the 
PYTHONHOME environment variable to [NSString 
stringWithFormat:@"%@/Frameworks/Python.framework/Versions/2.3", 
[[NSBundle mainBundle] bundlePath] (written in Mail, selectors may be 
wrong.. I did something slightly different in the code) so that Python 
could find its standard library.

I did notice one bug, AppHelper.runEventLoop() seems to crash if 
installMachInterrupt=True (the default) with a 10.2 PyObjC.  I haven't 
researched the issue, I simply made it false because I didn't need that 
functionality (it's basically to trap SIGINT) since the app was 
otherwise ready.

Developing this installer application gave me several ideas for new 
tools, libraries, and tutorials to write.  One of which is ripping 
bundlebuilder apart into tiny little orthogonal bits, and another is 
making a bdist_pkg for distutils (that PackageManager should use in 
lieu of tarballs).  I'm also thinking that I should put some more work 
into aeve, because it's much better suited for *receiving* and 
*sending* apple events than appscript is, although it is pretty low 
level right now (but FAR FAR nicer than working with AEDesc myself) it 
worked out well for me with no surprises.

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20040628/93db217f/smime.bin


More information about the Pythonmac-SIG mailing list