Download and installation

Download

Version 0.21.2 of NumCosmo is the latest release version available at NumCosmo’s GitHub page github releases.

To compile NumCosmo on a Mac OS, you can use HomeBrew. The compilation steps can be found in NumCosmo GitHub actions, providing a detailed, step-by-step process.

Build Status License: GPL v3 Coverage Status

Install using conda

For non-developers, NumCosmo and all necessary dependencies can be installed using conda. If you don’t have conda installed, you can download the full Anaconda distribution from here or Miniconda from here.

Installing NumCosmo using conda-forge

To streamline the installation process of NumCosmo, conda-forge offers a convenient option. You have the flexibility to install NumCosmo either by explicitly setting the conda-forge channel or by utilizing a conda-forge-only environment, accessible for download here. Additionally, it’s worth noting that mamba, a faster and more robust alternative to conda, can be seamlessly used as a drop-in replacement.

Using Miniforge:

We recommend using Miniforge, to install NumCosmo from the conda-forge channel, which provides pre-compiled binaries for Linux and macOS. You can install it with: (assuming you have already installed Miniforge or have conda-forge in your channels list)

mamba install numcosmo

Developer installation

For developers, NumCosmo can be installed from the source code. This provides the latest version of the code on the master branch. It is recommended for those interested in contributing to the project.

Requirements

The requirements below can be found on most Linux distribution, click here for a list of packages names for debian-like distributions and here for rpm based distributions.

  • C compiler (gcc, clang, icc, etc)
  • Fortran compiler (gfortran, ifort, etc)
  • Glib >= 2.44.0 – Data structures, threads, portability, memory allocation, etc.
  • GSL >= 2.4 – Several computational tools.
  • GMP >= 4.3.2 – Big integers library.
  • MPFR >= 2.4.2 – Multiple precision float library.
  • GObject-introspection: Middleware layer between C libraries (using GObject) and language bindings. It is needed to use NumCosmo from other languages.
  • PyGObject – Needed to use NumCosmo from Python. Note that pygobject3 refers to the PyGObject version (not Python’s version).
  • CFITSIO – A library of C and Fortran subroutines for reading and writing data files in FITS (Flexible Image Transport System) data format.
  • FFTW3 >= 3.1.2 – Discrete Fourier transform library.
  • NLOpt – Several general purpose minimization algorithms.
  • libfyaml – A fancy 1.2 YAML and JSON parser/writer.

Optional packages

Installing Prerequisites

To streamline the installation process, we provide instructions for installing prerequisites on Debian-like systems (including Ubuntu) and Mac OS using Homebrew.

Debian-like Systems (including Ubuntu)

On Debian-like systems, you can install the required packages from the main repositories using the following command:

sudo apt-get install \
gobject-introspection \
gir1.2-glib-2.0 \
libgirepository1.0-dev \
gcc \
gfortran \
pkg-config \
libglib2.0-dev \
libgmp3-dev \
libmpfr-dev \
libgsl0-dev \
libfftw3-dev \
libopenblas-dev \
libflint-arb-dev \
libcfitsio-dev \
libfyaml-dev \
libnlopt-dev \
libhdf5-dev \
gtk-doc-tools

Mac OS using Homebrew

For Mac OS users, Homebrew simplifies the installation process. Execute the following command to install the required packages:

brew install \
gobject-introspection \
gsl \
gmp \
mpfr \
fftw \
cfitsio \
libfyaml \
nlopt \
gfortran \
gtk-doc \
glib \
openblas

Python packages using pip

For Python-related functionality and building system, install the following using pip:

pip install meson ninja pytest numpy

Building from repository:

To build from the git repository you can follow the steps below. These instructions are for developers, if you just want to use NumCosmo, you should install it using conda.

NumCosmo uses the meson build system, which requires python3. Meson is available on most distributions, but if you don’t have it, you can follow the instructions.

  • Configure the project, here we use the default options:
    git clone https://github.com/NumCosmo/NumCosmo.git
    cd NumCosmo
    meson setup build
    
  • Compile everything
    meson compile -C build
    
  • Optionally run the library unit testing
    meson test -C build
    
  • Install the library. Note that most developers don’t want to install the library since they want to update/modify the library without installing it.
    meson install -C build
    
  • To use the library without installing it, you need to export some environment variables. A script is generated in the build directory, so the user can just run (and optionally add to the shell initialization):
    source build/numcosmo_export.sh
    

MambaForge Installation Guide for NumCosmo Library

MambaForge streamlines the installation process for NumCosmo Library on Linux and Mac OS. These self-contained steps eliminate the need for additional instructions. Follow these guidelines when building from the repository or a release. Execute the following command to install the required packages, these commands must be executed in the root directory of the NumCosmo repository:

  mamba env create -n numcosmo_developer -f devel_environment.yml
  conda activate numcosmo_developer
  [[ -e $GCC_AR ]] && AR=$GCC_AR
  [[ -e $GCC_NM ]] && NM=$GCC_NM
  [[ -e $GCC_RANLIB ]] && RANLIB=$GCC_RANLIB
  meson setup build --libdir=$CONDA_PREFIX/lib --prefix=$CONDA_PREFIX
  meson compile -C build

To test the installation, run the unit tests:

  meson test -C build

If you prefer using the library without installation, export specific environment variables. A script is generated in the build directory for easy execution (and optional addition to shell initialization):

  source build/numcosmo_export.sh

This script sets essential environment variables such as LD_LIBRARY_PATH and PYTHONPATH, enabling library usage without installation. Keep in mind that these variables apply only to the current shell session, necessitating their execution each time a new terminal is opened. Additionally, these variables may cause meson setup to fail, so unset them before rerunning meson setup.

For library installation in your conda environment, use:

  meson install -C build

Note that during library development, run meson install each time you modify the library to reflect changes in the conda environment.

Compiling example_simple.c

cd $NUMCOSMO_DIR/examples

gcc -D_GNU_SOURCE -Wall example_simple.c -o example_simple -lnumcosmo -lgsl -lm $(pkg-config glib-2.0 gobject-2.0 --libs --cflags)

Post Directory