Skip to content

Build environment setup on OS X 10.12 Sierra

Martyn Gigg edited this page Mar 13, 2018 · 40 revisions

The following instructions setup the build environment for mantid using clang compiler and python provided by the system, and all the other dependencies installed with brew. The drawback is that one has little control over python version and OpenMP will not be found. Make sure you have Qt Creator IDE and optionally cmake (GUI) app installed.

  1. Install Xcode from AppStore
  2. Install Xcode command line tools
xcode-select --install
  1. Install home-brew package manager
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Add the necessary 'taps'

In order to be able to 'tap' the mantidproject/mantid 'tap' we need to have a couple of packages installed

brew install git
brew install git-lfs
brew tap mantidproject/mantid
brew tap caskroom/cask
brew tap cartr/qt4
brew tap-pin cartr/qt4
  1. Install the necessary dependencies. Note that some of these will bring brew python with them as dependency.
brew cask install xquartz
brew cask install mactex
brew install openssl
brew install cmake
brew install ninja --without-test
brew install qt@4 --build-bottle
brew install sip --build-from-source --without-python
brew install pyqt@4 --build-from-source
brew install qscintilla2qt4 --build-from-source --without-python
brew install qt --build-bottle
brew install pyqt --build-from-source
brew install qscintilla2 --build-from-source --without-python
brew install poco
brew install boost --c++11
brew install boost-python --c++11 --build-from-source
brew install gsl
brew install gcc
brew install hdf5 --c++11
brew install libmxml
brew install muparser
brew install nexusformat --c++11
brew install jsoncpp
brew install tbb --c++11
brew install opencascade --build-bottle
brew install qwt5
brew install qwtplot3d
brew install google-perftools
brew install librdkafka

If, while configuring Mantid, cmake complains that it cannot find sip, uninstall the package by brew uninstall --ignore-dependencies sip, reinstall it using the line above and follow the instructions on how to add Homebrew's site-packages to Python sys.path.

  1. Uninstall the brew python if it has been previously installed
brew uninstall --ignore-dependencies python3
  1. Install pip python package manager
sudo easy_install pip
  1. Install necessary python packages with pip
sudo -H pip install sphinx --ignore-installed
sudo -H pip install "ipython[notebook]==3.2.1"
sudo -H pip install qtpy
sudo -H pip install pycifrw
sudo -H pip install PyYAML==3.10
sudo -H pip install mock==1.0.1
sudo pip install sphinx_bootstrap_theme
sudo pip install psutil
sudo pip install qtawesome
sudo pip install "matplotlib>=2.1.2"
  1. Install h5py
brew install h5py
  1. Add Homebrew’s site-packages to your python path.
mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
  1. Git clone the mantid repository

  2. Disable the system integrity protection (SIP). To do this

    • restart the computer
    • before the apple logo appears press Command+R to enter the recovery mode
    • when in recovery mode, go to Utilities>Terminal and type
    csrutil disable
    
    • reboot again
  3. Now that SIP is disabled we can do the necessary patch:

cd /usr/include/python2.7
sudo cp pyport.h pyport.h.original
sudo patch pyport.h $MANTIDCHECKOUTROOT/buildconfig/pyport.patch
  1. Enable again the system integrity protection by repeating Step 12 and typing this time:
csrutil enable
  1. Open mantid project from Qt Creator, and you should be able to run cmake and build, given the right environment:

    • CC=/usr/bin/clang
    • CXX=/usr/bin/clang++
    • PATH=/usr/local/bin/:$PATH

Local bin contains the symlink to the brew packages, which have to come first in path, before /usr/bin. That's why it is important not to have python or clang (with this setup) in brew.

  1. Add to your .profile
export PYTHONPATH=$BUILDMANTID/bin
  1. You should now be able to mantid.