<html> <h1 id="homebrew_installation_instructions">Homebrew installation instructions</h1>

<p>The following install was successful (barring yet unseen bugs!) on Mountain Lion. If you wish to skip the fun of compiling by hand, you can follow the instructions below.</p>

<h2 id="install_homebrew">Install homebrew</h2>

<p>Homebrew is a package management system for Mac. It is under active development and has strict policies to protect the user from damage via software. They also seek to protect users from themselves by avoiding sudo commands as much as possible. It is recommended that you do NOT install homebrew alongside other package managers such as macports/fink. It seems to do just fine on its own. </p>

<p>To install homebrew, simply paste the following line into your favorite Mac terminal emulator:</p>

<pre><code>ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" </code></pre>

<p>To make sure everything is , run:</p>

<pre><code>brew doctor </code></pre>

<p>Add the following to your shell’s ‘rc’ file to source homebrew programs ahead of the system’s default versions:</p>

<pre><code>export PATH=/usr/local/bin:$PATH </code></pre>

<h2 id="install_important_stuff">Install important stuff</h2>

<h3 id="cvs_git">CVS/GIT</h3>

<p>CVS and GIT are version control systems. You can install them as follows:</p>

<pre><code>brew install git brew install cvs </code></pre>

<p>Excellent documentation for GIT is available at: https://www.atlassian.com/git/</p>

<h3 id="gcc_llvm">GCC/LLVM</h3>

<p>To compile EMAN2’s C++ code, we need to download a compiler. Here we install the homebrew versions of gcc and llvm, which are more up-to-date than those available on Mac by default.</p>

<pre><code>brew install gcc brew install llvm --with-clang --with-asan </code></pre>

<h3 id="cmake">CMake</h3>

<p>CMake is a family of tools designed to build, test and package software. It is used to generate the Makefiles for compiling EMAN2. We install the homebrew version as follows:</p>

<pre><code>brew install cmake </code></pre>

<h2 id="install_eman2_core_dependencies">Install EMAN2 core dependencies</h2>

<h3 id="qt4">Qt4</h3>

<p>Qt is a graphics library for cross-platform user interfaces. </p>

<pre><code>brew install qt </code></pre>

<p>If you need to incorporate additional qt features, check the output of</p>

<pre><code>brew options qt </code></pre>

<p>to see what else you can include.</p>

<h3 id="boost">Boost</h3>

<p>Boost is a set of useful, standardized libraries for C++. It is used to generate the Python-C++ interface in EMAN2. Homebrew comes with two ‘boost’ packages, and we’ll need both to generate the libraries required for compiling EMAN2:</p>

<pre><code>brew install boost brew install boost-python </code></pre>

<h3 id="gsl">GSL</h3>

<p>The GNU Scientific Library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting.</p>

<pre><code>brew install gsl </code></pre>

<p>A personal concern is that there is no option to ‘—enable-float’; however, I have not run into any problems with this yet.</p>

<h3 id="fftw">FFTW</h3>

<p>FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST). The most recent version is available from homebrew as follows:</p>

<pre><code>brew install fftw </code></pre>

<h3 id="berkeley_db">Berkeley DB</h3>

<p>The Oracle Berkeley DB family of open source, embeddable databases provides developers with fast, reliable, local persistence with zero administration. EMAN2 uses Berkeley DB as a mechanism for local storage of project metadata.</p>

<p>Oracle has made their most recent version very VERY proprietary. You need an account on their website to download the package, and you need a license to use 6.0.1. Instead, we can use homebrew, but we need to get a previous version since homebrew defaults to 6.0.1 (as of March, 2015). I managed to find instructions on Stack Overflow (https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula) that explain how to go about this and have reproduced them below:</p>

<pre><code>brew tap homebrew/boneyard brew versions berkeley-db # Copy the command after '5.3.28' cd $( brew --prefix ) git checkout fdc17de /usr/local/Library/Formula/berkeley-db.rb cd ${HOME} </code></pre>

<p>Now we can install berkeley-db just as we would any other package.</p>

<pre><code>brew install berkeley-db </code></pre>

<p>Finally, add the following to your shell’s ‘rc’ file to enable bsddb3 to know where berkeley-db is located:</p>

<pre><code>export BERKELEYDB_DIR=/usr/local/BerkeleyDB.5.3 </code></pre>

<p>At this point, I suggest that you refresh your shell.</p>

<h3 id="freetype">Freetype</h3>

<p>On Mac OS X 10.8 and later, X11 and Freetype are no longer included by default. Even if you are using an earlier Mac OS X, I recommend installing your own Freetype. Homebrew offers the most recent version of freetype, but we’ll need to explicitly include it in our configuration step later on.</p>

<pre><code>brew install freetype </code></pre>

<h3 id="ftgl">FTGL</h3>

<p>FTGL is a free, open source library to enable developers to use arbitrary fonts in their OpenGL applications. We can install it as follows:</p>

<pre><code>brew install ftgl </code></pre>

<h3 id="png">PNG</h3>

<p>The PNG (Portal Network Graphics) format provides lossless-compressed image support. Mac OS X 10.7 Lion ships with libpng 1.5, in which some deprecated features in the PNG API were removed. EMAN2 is being updated to use these new methods. For now, use libpng 1.2 if you are compiling on 10.7.</p>

<pre><code>brew install libpng </code></pre>

<h3 id="hdf5">HDF5</h3>

<p>HDF5 is a data model, library, and file format for storing and managing data. It supports an unlimited variety of datatypes, and is designed for flexible and efficient I/O and for high volume and complex data.</p>

<pre><code>brew install hdf5 </code></pre>

<h3 id="jpeg">JPEG</h3>

<p>Library for writing JPEG image files. Though optional, it’s very easy to install this package:</p>

<pre><code>brew install jpeg </code></pre>

<h3 id="tiff">TIFF</h3>

<p>Library for reading and writing TIFF image files. Install TIFF as follows:</p>

<pre><code>brew install libtiff </code></pre>

<h3 id="readline">Readline</h3>

<p>We can easily install ‘readline’ to parse command history in python as follows:</p>

<pre><code>brew install readline </code></pre>

<h2 id="install_eman2_python_dependencies">Install EMAN2 Python Dependencies</h2>

<p>Here we opt to use the homebrew version of python over the default install built against the system.</p>

<pre><code>brew install python </code></pre>

<p>This sets up a separate site-packages directory, installs ‘pip’ (a package management solution for Python), and allows us to ‘build’ our python library from scratch, incorporating only the components we want/need.</p>

<p>For further project specificity, we could opt for a virtual environment, which can be created after installing:</p>

<pre><code>pip install vrtualenv </code></pre>

<p>An explanation of the innerworkings of python virtual environments are beyond the scope of this document; however, you can find more information here: http://docs.python-guide.org/en/latest/dev/virtualenvs/</p>

<h3 id="sip">SIP</h3>

<p>SIP is a tool that makes it very easy to create Python bindings for C and C++ libraries. It was originally developed to create PyQt, the Python bindings for the Qt toolkit, but can be used to create bindings for any C or C++ library.</p>

<pre><code>brew install sip </code></pre>

<h3 id="pyqt4">PyQt4</h3>

<p>PyQt4 provides Python bindings for Qt4.</p>

<pre><code>brew install pyqt </code></pre>

<h3 id="bsddb3">BSDDB3</h3>

<p>bsddb3 provides Python bindings for the Berkeley DB API.</p>

<p>Having previously defined the BERKELEYDB_DIR environment variable, we can install bsddb3 with pip very easily:</p>

<pre><code>pip install bsddb3 </code></pre>

<h3 id="pyopengl">PyOpenGL</h3>

<p>PyOpenGL provides Python bindings for OpenGL. There is a pip package for it, available here:</p>

<pre><code>pip install PyOpenGL </code></pre>

<p>For the sake of optimization, pip also possesses an acceleration package that you can install in addition:</p>

<pre><code>pip install PyOpenGL-accelerate </code></pre>

<h3 id="ipython">iPython</h3>

<p>IPython provides a rich toolkit to help you make the most out of using Python interactively. EMAN2 uses iPython for the “e2.py” interactive interpreter environment.</p>

<pre><code>pip install ipython </code></pre>

<p>For more details about ipython and its many growing features, see: http://ipython.org/</p>

<p>If you’re interested in any of the recent developments in reproducible research and web/cloud-based python programming, I suggest using the following line to install ipython</p>

<pre><code>pip install "ipython[all]" </code></pre>

<p>and checking out the ‘Jupyter’ project online: http://jupyter.org/</p>

<h3 id="matplotlib">Matplotlib</h3>

<p>Matplotlib is a python 2D and 3D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments. It can be installed with the following line:</p>

<pre><code>pip install matplotlib </code></pre>

<p>For examples and inspiration, see: http://matplotlib.org/gallery.html</p>

<h3 id="readline_python">Readline (python)</h3>

<p>Homebrew has a version of readline; however, so does python. We install it here, too, for good measure.</p>

<pre><code>pip install gnureadline </code></pre>

<h2 id="as_a_final_precaution">As a final precaution</h2>

<p>Cleaning things up and ensuring that everything has been installed properly, run:</p>

<pre><code>brew linkapps brew cleanup brew doctor </code></pre>

<p>Most warnings observed when running ‘brew doctor’ are harmless, especially if you don’t use homebrew extensively. Unless problems arise later on, we recommend ignoring them.</p>

<h2 id="download_eman2">Download EMAN2</h2>

<p>First, obtain the EMAN2 source either via a stable source release, the nightly source release, or using CVS (if you have access permissions; a CVS tutorial is beyond the scope of this document).</p>

<h3 id="non_developer_from_source_officnato">Non-developer-from-source-officnato:</h3>

<p>Download EMAN2 from the NCMI: http://ncmi.bcm.tmc.edu/ncmi/software/software<em>details?selected</em>software=counter_222</p>

<h3 id="developer">Developer:</h3>

<p>Next, check out eman2 from CVS:</p>

<ol> <li><p>Get account on blake and be cleared to access CVS </p></li> <li><p>Set up CVS variables on .bashrc file:</p>

<pre><code>export CVSROOT=username@blake.bcm.edu:/usr/local/CVS/CVS export CVS_RSH=ssh </code></pre></li> <li><p>Make ‘src’ directory wherever you want the source code to be</p>

<pre><code>mkdir ~/src </code></pre></li> <li><p>Inside src, make ‘build’ directory</p>

<pre><code>cd ~/src && mkdir build </code></pre></li> <li><p>Inside src, download the source code</p>

<pre><code>cd ~/src && cvs co eman2 </code></pre></li> </ol>

<h2 id="configure_eman2">Configure EMAN2</h2>

<ol> <li><p>Go to ‘build’ and type</p>

<pre><code>ccmake ../eman2 </code></pre></li> <li><p>Link all libraries properly. </p></li> </ol>

<p>When using Homebrew, this phase takes a little more care to get right. I suggest comparing your screen to the one I’ve pasted below:</p>

<pre><code>BOOST_INCLUDE_PATH /usr/local/include BOOST_LIBRARY /usr/local/lib/libboost_python.dylib CMAKE_BUILD_TYPE CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT CMAKE_VERBOSE_MAKEFILE OFF EMAN_INSTALL_PREFIX /Users/jmbell/src/EMAN2/eman2 ENABLE_AUTODOC OFF ENABLE_BOUNDS_CHECKING OFF ENABLE_DEBUG OFF ENABLE_EMAN_CUDA OFF ENABLE_FFTW2 OFF ENABLE_FFTW3 ON ENABLE_FFTW_PLAN_CACHING ON ENABLE_FFT_CACHING OFF ENABLE_FTGL ON ENABLE_HDF5 ON ENABLE_IOCACHE OFF ENABLE_JPEG ON ENABLE_MEMDEBUG OFF ENABLE_MEMDEBUG2 OFF ENABLE_NATIVE_FFT OFF ENABLE_NFFT2 OFF ENABLE_OPENGL ON ENABLE_OPTIMIZE_MACHINE OFF ENABLE_OPTIMIZE_MOUNTAIN_LION ON ENABLE_OPTIMIZE_WINDOWS_VC OFF ENABLE_OPTIMIZE_X86_64 OFF ENABLE_OPTPP OFF ENABLE_PNG ON ENABLE_PROFILE OFF ENABLE_RT ON ENABLE_SPARX_CUDA OFF ENABLE_TIFF ON ENABLE_V4L2 OFF FFTW3_INCLUDE_PATH /usr/local/include FFTW3_LIBRARY /usr/local/lib/libfftw3f.dylib FREETYPE_INCLUDE_PATH /usr/local/include/freetype2 FREETYPE_LIBRARY /usr/local/lib/libfreetype.dylib FTGL_INCLUDE_PATH /usr/local/include FTGL_LIBRARY /usr/local/lib/libftgl.dylib GSL_CBLAS_INCLUDE_PATH /usr/local/include GSL_CBLAS_LIBRARY /usr/local/lib/libgslcblas.dylib GSL_INCLUDE_PATH /usr/local/include GSL_LIBRARY /usr/local/lib/libgsl.dylib HDF5_INCLUDE_PATH /usr/local/include HDF5_LIBRARY /usr/local/lib/libhdf5.dylib JPEG_INCLUDE_PATH /usr/local/include JPEG_LIBRARY /usr/local/lib/libjpeg.dylib NUMPY_INCLUDE_PATH /usr/local/lib/python2.7/site-packages/numpy/core/include PNG_INCLUDE_PATH /usr/local/include PNG_LIBRARY /usr/local/lib/libpng.dylib PYTHON_INCLUDE_PATH /usr/local/Frameworks/Python.framework/Headers PYTHON_LIBRARY /usr/local/Frameworks/Python.framework/Versions/2.7/lib/libpython2 TIFF_INCLUDE_PATH /usr/local/include TIFF_LIBRARY /usr/local/lib/libtiff.dylib ZLIB_LIBRARY /usr/lib/libz.dylib </code></pre>

<p>Once you’re happy with the links, press ‘c’ to configure and then ‘g’ to generate the makefile. </p>

<ol> <li><p>Still inside build type:</p>

<pre><code>make -j24 && make install -j24 </code></pre></li> <li><p>Add the EMAN2 folder (and the examples folder therein) to your PATH via the .bashrc file</p>

<pre><code>export EMAN2DIR=${HOME}/username/EMAN2 export PATH=$EMAN2DIR/bin:$PATH export PATH=$EMAN2DIR/examples:$PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EMAN2DIR/lib export PYTHONPATH=$PYTHONPATH:$EMAN2DIR/lib </code></pre></li> </ol>

<p>This should do it. If the building process goes through without errors, the basic tests to see whether EMAN2 is actually installed properly, are </p>

<ol> <li>A) Run e2speedtest.py from the command line</li> <li>B) Run e2.py from the command line</li> <li>C) Run e2display.py from the command line (assuming you’re not on a cluster)</li> </ol>

<p>If everything went well, the above should run without failure and you can begin using EMAN2. If not, please double check that you’ve followed all instructions. If you have, feel free to post to the EMAN2 google group for assistance.</p>

<h2 id="developers_more_for_you">Developers (More for you!)</h2>

<pre><code>brew install doxygen brew install gnu-indent pip install scipy skimage pip install </code></pre>

</html>