Skip to content

InstallFiPy%2FMacOSX%2FSnowLeopard

Jonathan Guyer edited this page Sep 26, 2014 · 1 revision

Table of Contents

Building a 64-bit scientific python environment for FiPy from source

The following generally follows http://blog.hyperjeff.net/?p=160 (Last updated: Wed, Nov 11, 2009, 4:03am), but had to be modified somewhat.

 * Be sure to use the "System" python. The ones from http://www.python.org and 
   [http://www.activestate.com/activepython/ ActiveState] don't appear to build
   proper 32/64 Universal libraries. You want `/usr/bin/python`. Make sure
   your `$PATH` isn't picking up another one. You may also need to set
   aside any `python` executable in `/usr/local/bin`.
 * Make sure that `/sw` ([http://www.finkproject.org fink]) and `/opt` 
   ([http://www.macports.org !MacPorts]) are not on any of your `$PATH`s. There may
   be viable ways to get running with those (and we will explore them in
   the future) but they aren't compatible with this one.

Finally, this has all been written as though you're using `bash` (which is the Snow Leopard default). If you're using a `tcsh` variant, then you'll need to replace all of the `export` statements with appropriate `setenv` statements.

Developer Tools

Install Xcode from your Snow Leopard install DVD or from the Apple Developer site.

virtualenv

This is the main departure from hyperjeff's instructions. virtualenv avoids the need to meddle with the System's NumPy and is just generally a cleaner way to work.

 * Install [http://pypi.python.org/pypi/distribute distribute], 
   * ''alternatively, you can install [http://pypi.python.org/pypi/setuptools setuptools], but distribute
    seems to be the more "modern", supported way to accomplish the same
    tasks. With `setuptools`, you will need to replace each instance of `pip install` with `easy_install`.''
 * Install [http://www.pip-installer.org/en/latest/index.html pip]
 * Install [http://pypi.python.org/pypi/virtualenv virtualenv]
 * Optionally (recommened) install [http://www.doughellmann.com/projects/virtualenvwrapper/ virtualenvwrapper]
   and add
   to your `.bashrc` file (or other appropriate startup file).
 * Set up your virtual environment
   Substitute any name you like for `{python64}`.
   * ''if you didn't install `virtualenvwrapper`,
   ''

Set up a scratch directory

E.g.

gfortran

Get and install gfortran. There are various other ones out there, but this one is strongly advised.

You can do this all graphically, and you should be sure to check for the latest version, but you can do this from the command-line

CMake

Install CMake. I used `cmake-2.8.4-Darwin-universal.dmg`.

This one must be done with the GUI.


That's it for the sudo'ing

From now on, particularly if you take a break or open a new shell, be sure your virtual environment is active before each step, e.g.,

FFTW

 * Build
 * Optionally, test with
 * Install

UMFPACK

Download and unpack the SuiteSparse code archives

METIS

 * Download, unpack, and build [http://glaros.dtc.umn.edu/gkhome/views/metis METIS] within the `SuiteSparse` directory
  * If necessary, rename the metis directory, e.g.,
   ''(or change every instance of `metis-4.0` to `metis-4.0.3` in every `Makefile`. I thought it was easier to rename the directory)''
 * Build
 * If desired, test `METIS` by following the directions in `Graphs/0README`.

UMFPACK

 * Go back to `SuiteSparse`
 * In `UFconfig/UFconfig.mk`, around line 281, uncomment
   Note that this file has been updated since hyperjeff's instructions and that `-arch i386 -arch x86_64` 
   from hyperjeff's instructions is not in the commented-out lines in the package I downloaded. I omit them to no
   apparent harm.
 * Build

No need to install this.

NumPy

 * Ensure that you have installed [wiki:SnowLeopardSourceBuild#FFTW FFTW]
 * Ensure that you have installed [wiki:SnowLeopardSourceBuild#UMFPACK UMFPACK]
 * Set up the build environment
 * Get the source
   * ''You might choose instead to
    or [https://sourceforge.net/projects/numpy/files/ download a tarball],
    depending on your level of risk aversion.''
 * Tell NumPy about AMD and UMFPACK
   Edit `site.cfg`, around line 99
 * Build and install
 * Optionally, to test
  * Leave the `numpy` directory
  * Install [http://somethingaboutorange.com/mrl/projects/nose nose]
  * Test

Matplotlib

 * Get the source
 * I had to apply attachment:makeosx.patch
  Basically `zlib` is now at version 1.2.5, the `make` and the `install` of `zlib` need to be separate steps, and the `libpng` file repository has been rearranged. See http://sourceforge.net/tracker/?func=detail&aid=2981126&group_id=80706&atid=56072 (which has been incompletely applied to the Matplotlib source, as of this writing) and https://sourceforge.net/tracker/?func=detail&aid=3141312&group_id=80706&atid=560722.
 * Build and install
 * Test
 * Get, build, and install the source
 * Optionally, to test
   I get one failure in `Test/test_sparray.py` and a segmentation fault in `Test/test_superlu.py`, but Pysparse seems to work fine for FiPy's needs.

FiPy

Get the source

It is not necessary to install FiPy (we don't).

 * Simply add an appropriate 
 {{{
 export PYTHONPATH=/{path}/{to}/fipy:${PYTHONPATH}
 }}}
 to your `${VIRTUAL_ENV}/bin/postactivate` file  (best to move the `fipy/` directory you just checked out to a more permanent home than `~/fipytmp`) and then
 {{{
 python setup.py bdist_egg
 }}}
 * Alternatively, install like other packages with
 {{{
 python setup.py install
 }}}
 * Perhaps the best of both worlds is to move `fipy/` to someplace permanent and then
 {{{
 python setup.py develop
 }}}
 which will cause FiPy to be "installed", but will allow you to `svn update` the source when we make changes.

Optional Installs

At this point, FiPy should be basically functional. The following installs augment FiPy's capabilities, but some of them can be troublesome (or at least time-consuming) to build and install, so you may wish to wait until you need them.

!SciPy

Do NOT move the System NumPy library. virtualenv takes care of this.

Get the source

You might choose instead to

or download a tarball, depending on your level of risk aversion.

Now compile and install

Note, I had to add the `--fcompiler=gnu95` option to hyperjeff's instructions.

IPython

Get, build, and install the source

Mayavi

VTK

Clean up your build environment. Either launch a new shell and

or


If you have previously installed or built a custom Python, e.g., from python.org or from ActiveState, then you may have a `/Library/Frameworks/Python.framework`. If you do, it is imperative that the VTK build not see this. You can either move that framework aside (requiring `sudo`) or you can divert CMake's attention with

If, for some reason, you already have a `~/Library/Frameworks/Python.framework`, then you'll need to move that aside, whether or not you have a `/Library/Frameworks/Python.framework`. CMake is hard-wired to search, in order, for `~/Library/Frameworks/Python.framework`, `/Library/Frameworks/Python.framework`, `/System/Library/Frameworks/Python.framework`, and finally `/Network/Library/Frameworks/Python.framework` and we need it to find `/System/Library/Frameworks/Python.framework`. If anybody knows a CMake flag to direct it to do that, please pass it along.


Download, build, and install VTK

You'll also need to add

to your `${VIRTUAL_ENV}/bin/postactivate` script.

Now follow the standard Mayavi build instructions of your choice. I did:

ETS

Download, build, and install ETS

Mayavi

Download, build, and install Mayavi

sip

Download, build, and install sip

!PyQt

Install the Cocoa version of Qt. Be sure to get the "32-bit and 64-bit" installer.

Download, build, and install !PyQt

Trilinos

Swig

!PyTrilinos requires swig 1.3.38 or greater. You can check what you have with

Otherwise, download the latest from http://www.swig.org/download.html, unpack, and build

mpi4py

FiPy needs mpi4py for some aspects of parallel operations. If you only plan to use Trilinos in serial (you do? really?), you don't need this.

Trilinos

Obtain Trilinos 10

You'll also need to add

to your `${VIRTUAL_ENV}/bin/postactivate` script.

It is not clear why it is necessary to disable the Fortran compiler, but cmake fails otherwise.

Trilinos 10.6.4

Python 2.7.x has known problems with building some libraries for Mac OS X.

`${VIRTUAL_ENV}/include/python2.7` is a symlink. Find what it links to and replace it with a copy, e.g,

This will produce something like

Note the link destination and replace the link with a copy of that directory:

Search for `_PY_PORT_CTYPE_UTF8_ISSUE` in `${VIRTUAL_ENV}/include/python2.7/pyport.h` and make the changes (lifted from http://codereview.appspot.com/179049/patch/1/2)

Obtain Trilinos 10

Clean Up

You might wish to keep it around to perform other installs, but you're done with `~/fipytmp`, so, if desired, you can

Lion notes

There's a new gfortran in town. It seems to be easiest to get this with homebrew.

Clone this wiki locally