Skip to content

Installation

Miguel Zumalacarregui edited this page Aug 25, 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 latest release.

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:

./class gravity_models/brans_dicke.ini

Python wrapper

The wrapper is the CLASS classy module renamed to hiclassy, 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 hiclassy import HiClass

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

pip install hiclassy

which provides from hiclassy import HiClass. PyPI carries a source distribution rather than a wheel, so pip still compiles the C code locally (gcc and make required, a few minutes); what you save is managing the repository. For hands-on work with the source tree, the locally built classy is preferred.

Next steps

Clone this wiki locally