Develop with Conda on MacOS

Install Git

  • On MacOS install using brew with the following command: brew install git

Clone the mantid source code

  • There are 2 common ways developers have been doing this.

    • Using git in the terminal and cloning the codebase by calling git clone git@github.com:mantidproject/mantid.git in the directory you want the code to clone to. This sets you up with accessing the remote repository via SSH so make sure to setup git properly using this startup guide and ensure your ssh key is setup using this guide to Github with SSH.

    • Or by using GitKraken.

Install Mambaforge

  • Choose the latest version of Mambaforge-MacOSX-x86_64.sh for intel based Macs or for the new arm versions use Mambaforge-MacOSX-arm64.sh

  • Run your downloaded script from the terminal using bash Mambaforge-MacOSX-x86_64.sh or bash Mambaforge-MacOSX-arm64.sh depending on your downloaded variant.

  • If it asks whether or not you want to initialise conda with conda init, choose to do so.

  • Restart your terminal.

Setup the mantid conda environment

Create a Conda environment and install the mantid-developer Conda metapackage by following the steps below:

  • First create and activate a new conda environment. Here we have named it mantid-developer for consistency with the rest of the developer documentation but you are free to choose any name.

    mamba create -n mantid-developer
    mamba activate mantid-developer
    
  • Install the mantid-developer Conda metapackage from the mantid Conda channel. You will normally want the nightly version.

    mamba install -c mantid/label/nightly mantid-developer
    

Configure CMake and generate build files

  • Still using the terminal.

  • If not already activated in the previous step, run conda activate mantid-developer to activate your conda environment.

  • Navigate back to your mantid source directory using cd mantid if you used the default name during cloning from git.

  • Inside of your mantid source directory run cmake --preset=osx

    • Alternatively if you don’t want to have your build folder in your mantid source then pass the -B argument, overriding the preset, to cmake: cmake {PATH_TO_SOURCE} --preset=osx -B {BUILD_DIR}

How to build

  • Navigate to the build directory.

  • To build Mantid Workbench use: ninja

  • To build Unit Tests use: ninja AllTests

CMake Conda variables

The CONDA_BUILD parameter is used to customise our installation, which is required when we are using the conda-build tool to build and package Mantid. This option can be passed to CMake on the command line using -DCONDA_BUILD=True.

Running Workbench

To run workbench from the commandline, ensure you conda environment is activated and from the build directory:

cd bin
python workbench

Note

macOS developers will see the warning from Qt in the terminal:

An OpenGL surfcace format was requested that is either not version 3.2 or higher or a not Core Profile. Chromium on macOS will fall back to software rendering in this case. Hardware acceleration and features such as WebGL will not be available.

It can be safely ignored but is present as a reminder of some deprecated OpenGL functionality being used. It is only visible to developers and the spelling mistake is real.