-
Notifications
You must be signed in to change notification settings - Fork 122
Building Mantid on OS X 10.10 & 10.11 using clang and Xcode
These instructions are from the assumptions of a blank newly installed Mac and want to use the system python. Other python distributions may work but have not been tested.
- First install Xcode and then clone the mantid git repository.
- The last version to support OS X Mavericks is Xcode 6.2
- The last version to support OS X Yosemite is Xcode 7.2.1
- Our OS X El Capitan build server is currently running Xcode 7.3.1
-
Install Apple's Command Line tools (without this then /usr/include will not exist)
xcode-select --install
-
Install Homebrew. If you already have Homebrew and are upgrading the OS follow the instructions here:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
Add the necessary 'taps'
brew tap homebrew/science brew tap homebrew/python brew tap mantidproject/mantid brew tap caskroom/cask
-
Install required dependencies (will make a mantid-developer formula soon) If you plan on distributing your application bundle, change
brew install
tobrew install --build-bottle
brew cask install xquartz # mactex is optional, needed for parsing equations in qthelp documentation. brew cask install mactex brew install openssl brew install qt --with-qt3support --build-bottle brew install cmake # sip,pyqt and qscintilla2 bring in homebrew's python if # installed with --build-bottle. And add --build-from-source. brew install sip --build-from-source brew install pyqt --build-from-source brew install qscintilla2 --build-from-source # unit tests fail with 1.6.0. brew install poco --c++11 brew install boost --c++11 # boost-python brings in homebrew's python if installed with --build-bottle. 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 #removing tbb simplifies packaging brew install opencascade7 --without-tbb --build-bottle brew install qwt5 brew install qwtplot3d brew install google-perftools
-
Uninstall homebrew Python that some of the dependencies insist on installing
brew uninstall python
-
Optional: for cmake-gui
brew cask install cmake
-
Now to install the ipython stuff for the terminal in MantidPlot.
sudo easy_install pip sudo -H pip install sphinx # https://github.com/mantidproject/mantid/issues/13481 sudo -H pip install "ipython[notebook]==3.2.1" sudo -H pip install qtconsole sudo -H pip install pygments sudo -H pip install pyzmq
-
Install the theme for sphinx
sudo pip install sphinx_bootstrap_theme
-
Install other python dependencies
sudo pip install psutil brew install h5py
-
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
-
Now you need to patch a header in your python!
a. If building on the command line with make or ninja.
cd /usr/include/python2.7
or
cd /System/Library/Frameworks/Python.framework/Headers
then
sudo cp pyport.h pyport.h.original
sudo patch pyport.h $MANTIDCHECKOUTROOT/buildconfig/pyport.patch
b. If building with Xcode on OS X Yosemite
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
then
sudo cp pyport.h pyport.h.original
sudo patch pyport.h $MANTIDCHECKOUTROOT/buildconfig/pyport.patch
Note: If Xcode updates for any reason, the patch will be lost.
-
Now run CMake and select the Xcode generator with the default native compilers.
-
Now open the project in Xcode (doing this from the command line to ensure the PYTHONPATH is correctly picked up by Xcode).
cd /path/to/my/build/dir open Mantid.xcodeproj
- The main problem that can arise is due to python path issues. This usually either arises at the CMake or Run from Xcode steps. It is because the PYTHONPATH is not being picked up.
- If you have upgraded to Mavericks (OS X 10.9) from a previous version of OS X with homebrew already installed then you may encounter some issues related to the fact that the default std lib has changed. The easiest way to avoid this is to remove and then re-install all your formulas.
- You may find that if you build the MantidPlot target then you will get errors when you run, such as Can't start python and Cannot load Curve Fitting Plugins, this is due to the fact that the MantidPlot target does not contain all the dependencies. You are best, if you are unsure of the hierarchy, to just use the ALL_BUILD target and then just switch to the MantidPlot target in order to run.
- NOTE that you might need to run
./MantidPlot.app/Contents/MacOS/MantidPlot
from theBUILD-DIR/bin
(instead ofopen MantidPlot.app
OR./MantidPlot
fromBUILD-DIR/bin/MantidPlot.app/Contents/MacOS/
) to get the library paths correct. Otherwise the issues above might show up (at least on OS X 10.11 El Capitan).