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 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 scipy
> cd scipy
> python 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,
- 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/ script to build PCRE just for SWIG to statically
link against. Run 'Tools/ --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
sudo make install

Back to SciPy and python 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:


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.

1 comment:

mtrichardson said...

Brew recently updated to include swig, so you can now 'brew install swig' after doing a 'brew update'.