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:
- Fetch the latest code from Ronald Oussoren:
hg clone https://bitbucket.org/ronaldoussoren/pyobjc cd pyobjc
- Compile and install PyObjC core:
(cd pyobjc-core && python3 setup.py install)
- 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
- 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.
I would change the first line of step 4 to for i in pyobjc-framework-[^X]*; do to prevent to try to build pyobjc-framework-XgridFoundation that will fail (and you might not need).
This seems to work OK with Xcode 5.1 installed on OS X 10.9.2.
See this nice example of a OS X Cocoa Application using Python and Interface Builder. It works with Python 3.
any help on getting the bindings to work when trying to compile from OS X 10.10 beta 1?
Running into a lot of only for OS X version >= 10.6
and this when trying to build cocoa:
Processing dependencies for pyobjc-framework-CoreData==3.1
Searching for pyobjc-framework-Cocoa>=3.1
No local packages or download links found for pyobjc-framework-Cocoa>=3.1
error: Could not find suitable distribution for Requirement.parse('pyobjc-framework-Cocoa>=3.1')
also when running python3 from the terminal and trying to import cocoa it fails
Post a Comment