Installation Instructions
Get started with NumCosmo
Download
Version 0.27.0 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.
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 can install NumCosmo either by explicitly setting the conda-forge channel or by utilizing a conda-forge-only environment, available for download here.
Using Conda
We recommend installing NumCosmo from the conda-forge channel, which provides pre-compiled binaries for Linux and macOS. You can install it with:
conda install -c conda-forge numcosmoOr if you have conda-forge in your channels:
conda install numcosmoCurrent release info
| Name | Downloads | Version | Platforms |
|---|---|---|---|
Development Environment
Conda Development Environment
Conda 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 commands in the root directory of the NumCosmo repository:
conda env create -n numcosmo_developer -f environment.yml
conda activate numcosmo_developer
pip install -v pygobject-stubs pytest-tap types-tabulate
meson setup build --libdir=$CONDA_PREFIX/lib --prefix=$CONDA_PREFIX
meson compile -C buildNote: The pip packages provide type stubs for better mypy type checking support during development.
To test the installation, run the unit tests:
meson test -v -C buildIf 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.shThis 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, so you’ll need to source this script each time you open a new terminal. Note that these variables may interfere with meson setup, so unset them before rerunning the setup command.
Installation
In general, developers do not need to install the library. However, if you wish to install it in your conda environment, use the following command:
meson install -C buildNote that during library development, you’ll need to run meson install each time you modify the library to reflect changes in the conda environment.
Other Development Environments
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 distributions. Click here for a list of package names for Debian-like 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.
Recommended packages
Optional packages
- Any optimized BLAS library (OpenBLAS, MKL, etc) Improves speed in linear algebra calculations, e.g.,
- Lapack – Linear Algebra PACKage
- gtk-doc – GTK-Doc is used to generate API documentation from comments added to C code, only needed to generate new releases.
- ARB – C library for arbitrary-precision interval arithmetic.
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-dev libcfitsio-dev libfyaml-dev libnlopt-dev \
libhdf5-dev gtk-doc-toolsNote: in recent Debian and Ubuntu releases, the package name changed from libflint-arb-dev to libflint-dev.
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 openblasPython packages using pip
For Python-related functionality and the build system, install the following using pip:
pip install meson ninja pytest numpyFor development with type checking and additional testing tools (type stubs provide better mypy support):
pip install pygobject-stubs pytest-tap types-tabulateBuilding from repository
To build from the git repository, 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 and requires Python >= 3.11. 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 -v -C build- Install the library (optional). Note that most developers don’t want to install the library since they prefer 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 that you can source (and optionally add to your shell initialization):
source build/numcosmo_export.shCompiling 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)