Skip to content

Build environment setup on OS X 10.12 Sierra

Gagik Vardanyan edited this page May 11, 2017 · 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.

  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'
brew tap homebrew/science
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 mactex
brew install openssl
brew install cmake
brew install qt@4 --build-bottle
brew install sip --build-from-source
brew install pyqt@4 --build-from-source
brew install qscintilla2qt4 --build-from-source
brew install poco
brew install boost --c++11
brew install boost-python --c++11 --build-from-source
brew install gsl
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
  1. Uninstall the brew python
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 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
  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:
crsutil 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.

CAVEATS:

OPENSSL:

A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs

and run /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include

SIP:

The sip-dir for Python is /usr/local/share/sip.

Python modules have been installed and Homebrew's site-packages is not in your Python sys.path, so you will not be able to import the modules this formula installed. If you plan to develop with these modules, please run: mkdir -p /Users/vardanyan/Library/Python/2.7/lib/python/site-packages echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/vardanyan/Library/Python/2.7/lib/python/site-packages/homebrew.pth

Clone this wiki locally