Installing the required tools on OSX

Most people will simply want to use the official OS X binaries that matplotlib provides at sourceforge. For those who want to build themselves, read on.

The following instructions describe how to install the basic tools for the Py4Science workshop on OSX. Charlie Moad, who does the official OS X builds for matplotlib, also has prepared these Matplotlib OS X Build Notes.

get access to the terminal

Put the "Terminal" on your dock launch bar. It is in the Applications->Utilities folder

install gcc and other developer tools

Install XCode developer tools from the Leopard install CD under optional packages. Verify the install -- check for a working gcc

 > gcc --version
 i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)

If you don't have the cd (or not a very recent one), you can get XCodetools from the Apple Developer Connection:

http://developer.apple.com/tools/download/

you may have to join (for free) and login.

get the mac python python release

The consensus is that the python that ships with Apple is broken and should be replaced with the universal binary from the mac python community. Go to the mac python site for downloads and install the python 2.5 universal binary from there:

Verify the python install

>  /usr/local/bin/python
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Make sure that /usr/local/bin is in your $PATH before the Apple defaults. I added this to the front of my default .bash_profile

PATH="/usr/local/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH

Start a new terminal instance and verify

 > which python
 /usr/local/bin/python

NOTE: The installer should have added the Python Framework binary directory to your PATH by default, so that typing "python" will get you the new version. It edited by .profile for me. Try typing "python" at the prompt and sew hatyou get before doing the above )though you amy want /uar/local/bin on your PATH for other things anyway.

Get whatever else you want from pythonmac.org

get svn checkouts of MINS

I am going to be installing most things from svn since I need developerversions of many packages, but you may just want to get the latest stable releases from this pythonmac site. In particular, I always run svn ipython, numpy, scipy and matplotlibx

ipython

   > svn co http://ipython.scipy.org/svn/ipython/ipython/trunk ipython
   > cd ipython
   > sudo python setup.py install

numpy

   > svn co http://svn.scipy.org/svn/numpy/trunk numpy
   > cd numpy
   > sudo python setup.py install

scipy

   > svn co http://svn.scipy.org/svn/scipy/trunk scipy

  > sudo tar -xvzf gfortran-intel-leopard-bin.tar.gz -C /

matplotlib

matplotlib wants a GUI, so I am going to try wxpython2.8, which is available from the pythonmac ite. Because I am interested in installing the enthought tools which need wxython (eg traits UI) I'm going to see if I can get a wx enabled build of mpl going. I installed wxPython2.8-osx-unicode-2.8.3.0-universal10.4-py2.5.dmg from the pythonmac site and am crossing my fingers that I don't find myself entangled in wx version hell.

 > svn co  https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib

matplotlib depends on libpng and freetype, both of which are provided by the xcode package in /usr/X11R6, so I am going to point the mpl build to that directory. sys.platform is "darwin", so edit setupext.py and add '/usr/X11R6' to the "basedir" dictionary for the 'darwin' key. You need to install pkgcong-0.22 from http://pkgconfig.freedesktop.org/releases/ (just configure, sudo make install it) so that matplotlib can use it to find an properly configure png and freetype. You will need to set the pkgcong path

 > export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig

There is a bug in the apple compiler that ships with OS X 10.5 that causes a compiler error with our agg extension with the default optimization level. To work around that, set -Os as the default optimization level. Here is the build command I use (it is also in the Makefile in the matplotlib src directory as 'make build_osx105'

  > CFLAGS="-Os -arch i386 -arch ppc" LDFLAGS="-Os -arch i386 -arch ppc" python setup.py build
  > sudo python setup.py install

and successfully make a figure with

 > ipython -pylab
 >>> plot([1,2,3])

which used the wxagg backend.

Py4Science/InstallationOSX (last edited 2008-06-06 01:57:37 by JohnHunter)