This is primarily just my scattershot notes on getting myself ready for
Python and C development on Mac. It really is a confusing picture as to
how to get started with Python development on the Mac. You can get a
bunch of bits and pieces from the official Mac page for Python , the
Python/Mac FAQ and a few other places, but it's hard to put it al
together to understand how The OS X bundled Python, MacPython, Fink,
MacPorts, framework or non framework, etc. all fit together, and how to
navigate the options. It didn't help that important Wiki pages such as
the FAQ had been vandalized, and I was not able to fix it for some
It seems to me that the reason for all this confusion is that a person just needing to run some cool Python script they downloaded would go about things in a very different way from someone like me who needs to heavily maintain software that uses advanced Python/C facilities. It all comes down to the split personality that comes from the OS X way of life superimposed upon the UNIX way of life.
Picking a distribution
- this note about how to use distutils to build a redistributable package MacPython, and these follow-ups: 1 2 3.
- This note on Uninstalling MacPython
The key section from the FAQ is the following, pasted from the diff of the vandalized page:
Q: Python overload! I've got Apple's Python, Jack's Python, Fink's Python... A: Newcomers to Python-on-X are often confused by the several distributions of Python available. Each flavor has a history and a reason for existance, but if you're starting out, you probably want to look at the "official unofficial" builds of MacPython 2.4 on http://undefined.org/python and install additional packages like numarray or PIL from http://pythonmac.org/packages. These builds have a feature set that supersedes that of the beloved 'official MacPython builds' by Jack Jansen and solve many of the obstacles that are described by the FAQ entries on this page.
I followed this advice and went with MacPython, but I also set up MacPorts for some flexibility (see below).
Getting started with MacPython (including setuptools)
I grabbed and installed python-2.5-macosx.dmg dmg/python-2.5-macosx.dmg from the page recommended in the FAQ.
I went with the approach of MacPython in system directories, but
packages I build from source in my home directory. This meant the
following in my
~/.profile, for a start, added after the "# Setting
PATH for MacPython 2.5" section added by the MacPython installer.
export PATH=$HOME/bin:/usr/local/bin:$PATH export PYVERSION=2.5 export PYSITE=$HOME/Library/Python/$PYVERSION/site-packages export PYTHONPATH=$PYSITE
And then the following in
[install] install_lib = ~/Library/Python/$py_version_short/site-packages install_scripts = ~/bin
I also had to do a one-time
mkdir ~/bin mkdir -p $PYSITE
I used setuptools for the first 4Suite and Amara install, following the
OS X specific
One wrinkle was that Firefox 188.8.131.52 refused to save the page with ez_setup.py so I could run it. I tried changing locations and all that to no avail. Smells like a bug. I just used Safari to get it in the end. I noticed that OS X doesn't seem to come with wget. After this set-up, a simple:
Worked like a champ, and so I had 4Suite and Amara installed. I also got them set up in CVS easily enough, with the above basic config in place.
Click Customize, expand the Applications category and click the checkbox beside X11 SDK to add it to the default items.
But the XCode 2.4.1dmg I got had "X11 SDK" greyed out. I just went ahead anyway, and it turns out you must install X11 itself before XCode will allow you to install the X11 SDK. Makes sense, but the instructions on the install page have this backward.
As for installing X11 itself, the page says:
Insert the OS X 10.4 installation DVD and run the package named Additional Software.
For the MacBook Pro the installation DVD is labeled "Mac OS X Install Disc 1". The package is actually named "Optional Installs". I clicked through until I got to the page where I could select X11:
You also need to use sudo for the ports update, which isn't clear in the instructions:
sudo port -vd selfupdate
And that's really about as far as I got. I installed MacPorts just to have it handy, just in case. I might first put it to use for wget, which I won't be able to live without very long, and really should come with OS X.