Random ramblings about Mac, Python, TeX, programming, and more  |     |          |     |  


Python 3 and PyObjC

November 27, 2012  |  os-x, programming, python

My main programming platform is OS X 10.8 and Python 3 (currently Python 3.3). In earlier blog posts I have discussed installing and using PyCrypto in this environment. My next attempt was to find a GUI solutions for this platform. I usually prefer native approaches when programming, and for OS X the Cocoa framework is the native approach. To get access to this from Python we need a bridge, and the bridge is called PyObjC. At the home page PyObjC seems like a dead project. But Ronald Oussoren is still doing some development, including Python 3 support. It is not straight forward to compile and install PyObjC for Python 3, but Giacomo Lacava provides the necessary steps. To summarize I have done the installation using the following steps:

  1. Fetch the latest code from Ronald Oussoren:
    hg clone https://bitbucket.org/ronaldoussoren/pyobjc
    cd pyobjc
    
  2. Compile and install PyObjC core:
    (cd pyobjc-core && python3 setup.py install)
    
  3. Compile and install the Cocoa, CoreData and Quartz frameworks:
    for i in Cocoa Quartz CoreData; do
      (cd pyobjc-framework-$i && python3 setup.py install)
    done
    
  4. Compile and install the rest of PyObjC (except the XgridFoundation framework):
    for i in pyobjc-framework-[^X]*; do
      (cd $i && python3 setup.py install)
    done
    

So far everything seems to work OK. You need Mercurial (hg) to perform the first step.

Last updated: November 27, 2012