Skip to content

Installation

Miguel Zumalacarregui edited this page Aug 20, 2026 · 2 revisions

Installation

How to get and compile hi_class, and how to install the Python wrapper.

Requirements

  • A C compiler (gcc by default; icc and pgcc are supported via the Makefile).
  • For the Python wrapper: Python 3 with numpy, cython, setuptools and wheel (they are declared as build requirements and pulled in automatically when installing with pip).

Getting the code

git clone https://github.com/hiclass-code/hi_class_public.git
cd hi_class_public

or download the zip of the hi_class branch.

Compiling the C code

make class

produces the class executable. Compiler, optimization flags (OPTFLAG = -O3 by default) and OpenMP are set at the top of the Makefile — uncomment -fopenmp in OMPFLAG to enable parallel execution.

Test the build (the output directory must exist before running):

mkdir -p output
./class gravity_models/brans_dicke.ini

Python wrapper

The wrapper is the standard CLASS classy module, extended with hi_class functionality (see Python wrapper). Build the C library and install the module in one step:

PYTHON=python3 make all

(make all builds class, libclass.a and then runs pip install . for the wrapper; the PYTHON= prefix is only needed if plain python is not your Python 3.) Equivalently, run pip install . directly from the repository root — its build step compiles libclass.a for you. Installing into a virtual environment is recommended. Then:

from classy import Class

Alternatively, a prebuilt wrapper is published on PyPI as hiclassy:

pip install hiclassy numpy scipy

which provides from hiclassy import HiClass without compiling anything locally. For hands-on work with the source tree, the locally built classy is preferred.

Next steps

Clone this wiki locally