Installing PyObjC

Support versions

PyObjC is regularly tested with Python 2.7, 3.2, 3.3 and the CPython trunk. Python 2.6 should also work, but is not tested as often.

PyObjC is regularly tested on Mac OS X 10.8 and should work on Mac OS X 10.5 or later for the i386, x86_64 and ppc architectures. PPC64 (64-bit on PowerMac G5 or iMac G5 systems) is not supported.

Requirements

PyObjC contains extensions and is distributed as source code. You therefore need a compiler to install PyObjC. The easiest way to get a compiler is do download Xcode from the Mac App Store.

Depending on the Python release you may need to install the Command Line Tools for Xcode. To install the Command Line Tools first open Xcode and then open the Xcode preferences. The downloads tab contains an option “components” and that list contains an option to install the “Command Line Tools”.

Note

The Command Line Tools package is not automaticly updated when you install a new version of Xcode. Every time Xcode is updated through the Mac App Store you need to start Xcode to check if there is a new version of the Command Line Tools.

Installation

PyObjC is distributed as a collection of Python packages that use distribute and can be installed using both easy_install and pip. Manual installation is also supported, but is a lot more work and is therefore more of a power-user feature.

Installation using easy_install

Installing or upgrading PyObjC using easy_install is easy:

$ easy_install -U pyobjc

Note

Due to issue 21 installing will take take quite some time because the package pyobjc-core is compiled a number of times.

The work around is to install that package before installing the rest of PyObjC:

$ easy_install -U pyobjc-core
$ easy_install -U pyobjc

Warning

Building on OSX 10.7 or 10.8 might give a compiler error when using Xcode 4 and a binary installer for Python. When installing fails because a compiler named ‘gcc-4.2’ cannot find the header ‘stdarg.h’ you have to install using a slightly different procedure:

$ env CC=clang easy_install -U pyobjc-core
$ env CC=clang easy_install -U pyobjc

Installation using pip

Installing or upgrading PyObjC using pip is easy:

$ pip install -U pyobjc

Note

Make sure that you don’t have a directory named “build” in the current working directory when you run pip, that might result in unexpected behavior.

Note

As with easy_install installing PyObjC takes quite some time due to issue 21 and the same workaround applies:

$ pip install -U pyobjc-core
$ pip install -U pyobjc

Warning

Building on OSX 10.7 or 10.8 might give a compiler error when using Xcode 4 and a binary installer for Python. When installing fails because a compiler named ‘gcc-4.2’ cannot find the header ‘stdarg.h’ you have to install using a slightly different procedure:

$ env CC=clang pip -U pyobjc-core
$ env CC=clang pip -U pyobjc

Manual installation

Manual installation is slightly involved, but still pretty easy.

  • First download the source code packages from the cheeseshop, you need at least pyobjc-core and pyobjc-framework-Cocoa. You do not need pyobjc, that’s a helper package that is only used to pull in the other packages when installing using easy_install or pip.

  • Extract the archives

  • Install every packages using the standard recipe for Python package installation:

    $ python setup.py install
    

    Due to package dependencies you need to install the packages in a particular order:

Advanced installation options

PyObjC for PowerPC systems

To build a version of PyObjC that runs on PowerPC systems you need a system running Mac OS X 10.6 (or earlier) running Xcode 3. The version of Xcode that is available in the Mac App Store can not create PowerPC binaries.

Distributing binaries to other Mac OS X releases

It is possible to create self-contained application bundles for PyObjC based application using py2app. You do need to take some care when you want to ship these applications to machines running a different version of Mac OS X than the one you used for the build

  • Later versions of Mac OS X should work fine

  • Earlier version of Mac OS X work fine, but you do need to ensure that Python itself is build with MACOSX_DEPLOYMENT_TARGET set to the earliest version of Mac OS X you want to support. PyObC, and other extension packages, should automaticly pick up the deployment target from the Python build.

    Note

    PyObjC contains code that explictly weak-links to a number of APIs that are not available on all Mac OS X releases.

    You might still end up with an application that won’t run on earlier releases when you use another extension module that (accidently) hard links to an API that is not available in the earlier release.