[Numpy-discussion] recompiling needed for binary module after numpy 1.0

Robert Kern robert.kern at gmail.com
Mon Jan 8 01:49:30 EST 2007


belinda thom wrote:

> There's other reasons --- mostly curiousity driven --- that motivate  
> me to try a "rawer" (e.g. source, non-pkg based) install:
> 
> 1) My current kludge only supports TkAgg, so I can't play w/the wx  
> backend at all. Have no idea why
> 2) My current kludge only works w/numpy; under Numeric, matplotlib  
> plotting dies.
> 3) If I used the numpy/scipy bundles from http://www.macpython.org/,  
> I'd get the C API error Sebastian was originally talking about. I  
> have no idea how to fix this.

The way to "fix" it is to use or build binaries of scipy and matplotlib that
were compiled against the same version of numpy that you have installed.

* Make sure that you have the latest version of XCode available for your system.
I believe this is 2.4.1 right now.

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

* Install a FORTRAN compiler suitable for your system. For a Universal build of
Python, you will need gfortran. Get binaries from here:

  http://hpc.sourceforge.net/

For PowerPC:

  http://prdownloads.sourceforge.net/hpc/gfortran-bin.tar.gz?download

For Intel:

  http://prdownloads.sourceforge.net/hpc/gfortran-intel-bin.tar.gz?download

Install them according to the instructions on that page.

* Get the source code for numpy. The latest release is 1.0.1 and would be a good
bet.

  http://downloads.sourceforge.net/numpy/numpy-1.0.1.tar.gz

* Unpack it and cd to the source directory in the Terminal.

* Run the setup script to build and install numpy.

  $ python setup.py build
  $ python setup.py install

Depending on how you've set up permissions inside the Python framework and
wherever you've configured scripts to be installed to, you might need to issue
the last command with root permissions using sudo.

* Get the source code for scipy. The latest release is 0.5.2 and would be a good
bet.

  http://prdownloads.sourceforge.net/scipy/scipy-0.5.2.tar.gz

* Unpack it and cd to the source directory in the Terminal.

* Run the setup script to build and install scipy. Be sure to use the following
command line arguments to ensure that your FORTRAN compiler is picked up correctly.

  $ python setup.py build_src build_clib --fcompiler=gnu95 build_ext
--fcompiler=gnu95 build
  $ python setup.py install

As with numpy, the latter command might need to be run with root permissions.


matplotlib is trickier because it has more external dependencies. I suggest you
ask on the matplotlib list for more information, but this is what I do:

* I install the appropriate wxPython binary. I'm currently using the wxPython
2.6 series since 2.8 is so new; I'm not sure if matplotlib works with it.
Depending on your Python version, use one of these:

http://downloads.sourceforge.net/wxpython/wxPython2.6-osx-unicode-2.6.3.3-universal10.4-py2.4.dmg
http://downloads.sourceforge.net/wxpython/wxPython2.6-osx-unicode-2.6.3.3-universal10.4-py2.5.dmg

* I use MacPorts to install the other dependencies.

  $ sudo port install libjpeg
  $ sudo port install libpng
  $ sudo port install libfreetype

* Now, get the matplotlib source. The latest release is 0.87.7 and is a good bet.

  http://downloads.sourceforge.net/matplotlib/matplotlib-0.87.7.tar.gz

* Unpack it and cd to the source directory in the Terminal.

* In order to tell matplotlib where to find the MacPorts libraries, you need to
edit setupext.py:

Index: setupext.py
===================================================================
--- setupext.py (revision 2861)
+++ setupext.py (working copy)
@@ -48,7 +48,7 @@
     'linux2' : ['/usr/local', '/usr',],
     'linux'  : ['/usr/local', '/usr',],
     'cygwin' : ['/usr/local', '/usr',],
-    'darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/local',
+    'darwin' : ['/opt/local', '/usr/local',
                 '/usr', '/sw'],
     'freebsd4' : ['/usr/local', '/usr'],
     'freebsd5' : ['/usr/local', '/usr'],


* Now just build and install like any other Python package.

  $ python setup.py build
  $ python setup.py install

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list