Wiki

Clone wiki

cosmosis / New Mac Installs

1. General Dependencies

On macOS, CosmoSIS is built using Apple's C and C++ compilers, and various tools installed using Homebrew.

Our general philosophy is to rely on Homebrew for as many compiled components as feasible. This allows us to leverage the Homebrew community's efforts to keep these compiled components up-to-date and compatible with each other. For this reason, we suggest keeping your Homebrew installation up-to-date.

The recommended build requires:

  • Apple's Command Line Tools, or Apple's Xcode
  • The GNU Compiler Collection (gcc), for the gfortran compiler; we do not use GNU's C or C++ compilers.
  • Python 3 (at the time of this writing, python 3.9)
  • git

and the following libraries:

Obtain Command Line Tools or Xcode

To obtain Apple's Command Line Tools, or Apple's Xcode, you must be enrolled in Apple's Developer Program. This is zero-cost, but requires that you register information with Apple. Information is available at https://developer.apple.com/programs/enroll.

The Command Line Tools are a much smaller download than Xcode, but do not include the Xcode IDE. Either is sufficient for working with CosmoSIS.

The installation of Homebrew requires this installation be done first.

Obtain Homebrew

Homebrew is package manager for macOS. The Homebrew site has instructions for installing Homebrew.

Obtain the Homebrew-supplied tools used by CosmoSIS

The brew install command is used to install software distributed by Homebrew.

brew install gcc gsl cfitsio fftw minuit2 openblas python numpy scipy mpi4py

This will install the named products, and also any other products upon which they depend. Note that the python installation with be the up-to-date python 3. This python will not be placed on your PATH, and doing so is not recommended for general work. The CosmoSIS setup script for macOS will put the necessary directory on PATH (as well as a few other similar actions) as it sets up for use of CosmoSIS.

Apple's Command Line Tools provides git, but you may want a newer version available from Homebrew:

brew install git

2. Download CosmoSIS and the CosmoSIS Standard Library

Download CosmoSIS and the CosmoSIS Standard Library (CSL) like this (we currently require the development version on macOS):

git clone --branch develop https://bitbucket.org/joezuntz/cosmosis
cd cosmosis
git clone --branch develop https://bitbucket.org/joezuntz/cosmosis-standard-library

3. Python Dependencies

Make sure you are in the directory created by cloning the cosmosis repository when you do this part of the installation. This directory can be most easily identified by the fact it will d contain a subdirectory named cosmosis-standard-library.

Create the Python virtual environment

We use a Python virtual environment to make sure the several Python packages required by CosmoSIS are kept compatible, and to not collide with those you may use for other projects. This should be done in cosmosis directory created by cloning the cosmosis repository.

To create the virtual environment, use:

$(brew --prefix)/bin/python3 -m venv --system-site-packages local-venv

To activate the virtual environment, use:

source local-venv/bin/activate

When this virtual environment is activated, the python on your PATH will be the python3 installed from Homebrew. To see this, try:

realpath $(which python)
# Should /usr/local/Cellar/python@3.9/3.9.<point release>/Frameworks/Python.framework/Versions/3.9/bin/python3.9
# The exact value of <point release> will change as Homebrew updates its Python 3.9.

After you have completed installing CosmoSIS, this activation will be done for you automatically, whenever you run the CosmoSIS setup script.

Install the additional Python modules required by CosmoSIS

After activating the virtual environment, use:

# Caution: do not use "pip install"; that gets confused with the pip
# that will install packages into Homebrew's directories, rather than
# into the virtual environment.
python -m pip install --upgrade pip
python -m pip install -r config/requirements.txt

Deactivate the virtual environment

The setup script for CosmoSIS sets up the virtual environment, so we must deactivate the virtual environment before running the setup.

deactivate

Now you should see that the python on your path is the macOS system python, which is python 2.7:

realpath $(which python)
# Should be /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

4. Setup script

Run the command:

source config/setup-cosmosis-mac

You need to do this each time you open a new terminal.

5. Build

Run the command:

make

6. Usage

Test your installation by running:

cosmosis demos/demo1.ini

See the demo 1 page for an explanation.

If you quit your terminal shell and start a new one then you need to repeat this step:

source config/setup-cosmosis-mac

7. External Data Sets

For some use cases you may also want to install Planck or WMAP data:

  • planck data (optional; for some demos and for using Planck likelihoods. Go to the "cosmology" link)
  • wmap data (optional; for using WMAP likelihoods)

Updated