Thursday, August 4, 2011

SciPy on Lion (1)

I was looking for new things to do today, and realized I haven't really done much with SciPy. Their page about installing it is here. It seems like the developers are tired of dealing with people who can't get it installed and recommend that you download a binary or at least, install the Python.org version of Python first.

Apple ships its own version of Python with OS X. However, we strongly recommend installing the official Python distribution.


Of course, I wasn't gonna do that. There are other recommendations: that you really ought to get readline (somehow better than what comes with OS X), that you should get and use gcc-4.0 (only gcc-4.2 on Lion that I could find), that you should set LDFLAGS and FFLAGS and so on. I ignored it all.


> svn co http://svn.scipy.org/svn/scipy/trunk scipy
> cd scipy
> python setup.py build


The build fails with


unable to execute swig: No such file or directory



> brew install swig
Error: No available formula for swig


SWIG installation (download here) was a bit of a hiccup:


configure: error: in `/Users/telliott/Desktop/swig-2.0.4':
configure: error:
Cannot find pcre-config script from PCRE (Perl Compatible Regular Expressions)
library package. This dependency is needed for configure to complete,
Either:
- Install the PCRE developer package on your system (preferred approach).
- Download the PCRE source tarball, build and install on your system
as you would for any package built from source distribution.
- Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically
link against. Run 'Tools/pcre-build.sh --help' for instructions.
(quite easy and does not require privileges to install PCRE on your system)
- Use configure --without-pcre to disable regular expressions support in SWIG
(not recommended).

./configure --without-pcre
make
sudo make install


Back to SciPy and python setup.py build and problems as described here. I'm not too swift with this svn/git stuff so rather than find the patched version I just patched the files:

add #include <complex.h> to each of:


scipy/linalg/src/fblaswrap_veclib_c.c
scipy/lib/blas/fblaswrap_veclib_c.c.src
scipy/sparse/linalg/eigen/arpack/ARPACK/FWRAPPERS/veclib_cabi_c.c


And it seems to have built:


> python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy import *
>>>

I'll look into to testing it tomorrow.