Written by Wei Zhang on 05/01/2008

The following instructions will guide to install sparx and EMAN2 to your home

Here I assume you username is xxx, thus your home directory would either 
be /Users/xxx.

1. On Mac, please Install Xcode which is the collection of development tools (g++, make, etc).
   to http://developer.apple.com/tools/download/, download it and following the
   instructions on the screen.  It will require registration!

2. Download and unpack EMAN2/sparx source code

    The source code can be found via link: http://ncmi.bcm.edu/ncmi/software/counter_222/software_86,
    you might need register for it.

    After you get the file (eman2.nightly.source.tar.gz), move it to home directory and unpack it:

        tar -zxvf eman2.nightly.source.tar.gz

    which would create directory EMAN2 under your home directory,

NOTE: on multi-CPU machines all make commands can be changed to
make -j 4
where 4 is the number of CPUs available.  It will significantly reduce the time of compilation.

3. install 3rd party libraries:

    EMAN2 employs the following 3rd party libraries: fftw, gsl, boost, hdf5, jpeglib (optional), tifflib (optional).

    3.1 install fftw:

            cd $HOME/EMAN2/src
            curl http://www.fftw.org/fftw-3.1.2.tar.gz -o fftw-3.1.2.tar.gz
            tar -zxvf fftw-3.1.2.tar.gz
            cd fftw-3.1.2
            # enable the single precission version and shared library
            ./configure --enable-float --enable-shared
            sudo make install

        the last step will ask you for your password.

    3.2 install gsl (GNU Scientific library):

           cd $HOME/EMAN2/src
           curl ftp://ftp.gnu.org/gnu/gsl/gsl-1.10.tar.gz -o gsl-1.10.tar.gz
           tar -zxvf gsl-1.10.tar.gz
           cd gsl-1.10
           sudo make install

    3.3 install boost:

        Note: (1) the latest version is 1.35 but it seems to has some problem on Mac, we will stick to 1.34_1 for now.
              (2) to install boost library, boost-jam must be installed first

        3.3.1 install boost-jam
                cd #HOME/EMAN2/src
                curl http://internap.dl.sourceforge.net/sourceforge/boost/boost-jam-3.1.16.tgz -o boost-jam-3.1.16.tgz
                tar -zxvf boost-jam-3.1.16.tgz
                cd boost-jam-3.1.16
                sudo cp bin.macosxx86/bjam /usr/bin/

        3.3.2 install boost-1.34-1
            cd $HOME/EMAN2/src
            curl http://superb-west.dl.sourceforge.net/sourceforge/boost/boost_1_34_1.tar.gz -o boost_1_34_1.tar.gz
            tar -zxvf boost_1_34_1.tar.gz
            cd boost_1_34_1
            sudo bjam --toolset=darwin install

            <this may take a very long time!>

    3.4 install hdf5

         cd $HOME/EMAN2/src
         curl ftp://ftp.hdfgroup.org/HDF5/current16/src/hdf5-1.6.7.tar.gz -o hdf5-1.6.7.tar.gz
         tar -zxvf hdf5-1.6.7.tar.gz
         cd hdf5-1.6.7
         sudo make install

    3.5 install numpy

        cd $HOME/EMAN2/src
        curl http://superb-west.dl.sourceforge.net/sourceforge/numpy/numpy-1.0.4.tar.gz -o numpy-1.0.4.tar.gz
        tar -zxvf numpy-1.0.4.tar.gz
        cd numpy-1.0.4
        sudo python setup.py install

    3.5 about jpeglib and tifflib
        it is not recommended to install jpeglib and tifflib, since they conflict with system libraries 

4. install cmake
    cmake is used to compile eman2, to install it, got www.cmake.org, there is a binary version for mac os x.
    It has extension ".dmg": download it and follow the instructions to install it.
5. install EMAN2

    5.1 compilation
            cd $HOME/EMAN2/src/build
            cmake ../eman2
            ccmake ../eman2

        an interface will popup in which you have to setup environmental variables, set the following (replace your
        user name for xxx):

            ENABLE_BOOST       : ON
            ENABLE_JPEG        : OFF
            ENABLE_TIFF        : OFF

            BOOST_INCLUDE_PATH : /usr/local/include/boost-1_34_1
            GLU_LIBRARY        : /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
            GL_LIBRARY         : /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib      
            JPEG_LIBRARY       : /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ImageIO.framework/Resources/libJPEG.dylib 

        press 'c' to configure, then set up:

            BOOST_LIBRARY      : /usr/local/libboost_python-1_34_1.dylib

        press 'c' to configure, then press 'g' to generate make file and quit, then:

            make install    

        libraries should appear in directory /Users/xxx/EMAN2/lib/

    5.2 make symbolic links. The libraries start with "libpy" are actually python modules, unfortunately, python only 
        load file whose extension is ".so" or ".py", thus you must make symbolic link for these files. The following 
        script makelink.py can do it for you:

            #!/usr/bin/env python

            import os
            from sys import stdin
            from string import strip, split
            line = stdin.readline()
            while len(line) > 0 :
                line = strip( line )
                name, ext = split( line, '.' )
                assert ext=="dylib"
                assert name[0:5]=="libpy"
                cmd = "ln -s " + line + " " + name + ".so"
                os.system( cmd )
                print cmd
                line = stdin.readline()

         to use it, save it and copy it to ~/EMAN2/lib, and type:

             cd ~/EMAN2/lib
             chmod +x makelink.py
             ls libpy*.dylib | ./makelink.py

6. install IPython.

    ipython is used by sparx:

        cd $HOME/EMAN2/src
        curl http://ipython.scipy.org/dist/ipython-0.8.2.tar.gz -o ipython-0.8.2.tar.gz
        tar -zxvf ipython-0.8.2.tar.gz
        cd ipython-0.8.2
        sudo python setup.py install

7. setup the environment:

    add the following lines to your bashrc file:

        export PATH=$PATH:/Users/xxx/EMAN2/bin:/Users/xxx/EMAN2/sparx/bin
        export DYLD_LIBRARY_PATH=/Users/xxx/EMAN2/lib
        export PYTHONPATH=/Users/xxx/EMAN2/lib:/Users/xxx/EMAN2/sparx/libpy

   or in cshell in .cshrc:
        setenv  DYLD_LIBRARY_PATH /Users/pawel/EMAN2/lib
        setenv  PYTHONPATH  /Users/pawel/EMAN2/lib:/Users/pawel/EMAN2/sparx/libpy
        set path=( /usr/sbin /usr/bsd /usr/bin /usr/local/bin /bin /Users/pawel/EMAN2/bin /Users/pawel/EMAN2/sparx/bin .)

8. start sparx

    chmod +x /Users/pawel/EMAN2/sparx/bin/sparx
    now you should be able to start the non-GUI sparx

9. install sparx with GUI (optional)

   9.1 install Qt4
       Qt4 is used to build sparx GUI. To install it, go to http://trolltech.com/downloads/opensource, there
       is a Mac version (with extension dmg) available for download. Download it and following the instruction to install

   9.2 install sip

       sip is needed by PyQt4, to install it:

           cd $HOME/EMAN2/src/
           curl http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.7.4.tar.gz -o sip-4.7.4.tar.gz
           tar -zxvf sip-4.7.4.tar.gz
           cd sip-4.7.4
           python configure.py
           sudo make install

   9.2 install PyQt4

       PyQt4 is the python binding of Qt4, which is directly used by sparx, to install it

           cd $HOME/EMAN2/src
           curl http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-mac-gpl-4.3.3.tar.gz -o PyQt-mac-gpl-4.3.3.tar.gz
           tar -zxvf PyQt-mac-gpl-4.3.3.tar.gz
           cd PyQt-mac-gpl-4.3.3
           python configure.py # answer yes to question
           sudo make install
       you may need input your password for installation 

   9.3 install PyOpenGL

           cd $HOME/EMAN2/src
           curl http://superb-west.dl.sourceforge.net/sourceforge/pyopengl/PyOpenGL-3.0.0b1.tar.gz -o PyOpenGL-3.0.0b1.tar.gz
           tar -zxvf PyOpenGL-3.0.0b1.tar.gz
           cd PyOpenGL-3.0.0b1
           sudo python setup.py install
   9.4 install matplotlib

           cd $HOME/EMAN2/src
           curl http://superb-west.dl.sourceforge.net/sourceforge/matplotlib/matplotlib-0.91.2.tar.gz -o matplotlib-0.91.2.tar.gz
           tar -zxvf matplotlib-0.91.2.tar.gz
           cd matplotlib-0.91.2
           python setup.py install

    9.5 sparx GUI version should work by now.  

10.  if you have password for cvs you have to replace directories from the nightly snapshot and recompile the system
     10.1  Add to .cshrc file the following lines
     setenv CVSROOT :ext:your_user_name@blake.bcm.tmc.edu:/blake2/local/CVS/CVS
     setenv CVS_RSH ssh
     10.2  source .cshrc

     10.3  reload and recompile the system

     cd $HOME/EMAN2
     rm -rf sparx
     mkdir sparx
     cvs up -dP sparx
     chmod +x sparx/bin/sparx
     cd $HOME/EMAN2/src
     rm -rf eman2
     mkdir eman2
     cvs up -dP eman2
     cd $HOME/EMAN2/src/build
     cmake ../eman2
     make -j 2 && make install

11. install mpi module

    11.1 install mpi: MacPro comes with a pre-installed openmpi.

    11.2 install the python binding for mpi:

           cd ~/EMAN2/sparx/test/boostrap           
           gcc -DNDEBUG -O2 -g -D_GNU_SOURCE -DNUMPY -fPIC -I/usr/include -I/usr/include/python2.5   -I/Library/Python/2.5/site-packages/numpy/core/include/numpy  -c mympimodule.c -o mympimodule.o

           gcc -dynamiclib -single_module -o mpi.so  mympimodule.o /usr/lib/libpython.dylib /usr/lib/libmpi.dylib 
           mv mpi.so ~/EMAN2/lib

     11.3 test the mpi module:

           start sparx, type

                  import mpi

           if no error message, you python MPI module is OK.

Mac (last edited 2013-07-01 13:13:03 by localhost)