Skip to content
Pascal Horton edited this page Oct 16, 2024 · 16 revisions

How to build hydrobricks

There are different ways to build hydrobricks:

  • To work on the Python code, you should install it in editable mode (first instructions)
  • To build a Python wheel without installing development tools, use cibuildwheel (second instructions)
  • If you want to build the C++ core only, follow the instructions of the last section.

Build the Python module in editable mode

To build hydrobricks, you need:

  • A C++ compiler (GCC, Visual Studio)
  • CMake
  • Python 3

Create a Python virtual environment and activate it

python -m venv ~/venv_hb
# On Linux:
source ~/venv_hb/bin/activate
# On Windows
source ~\venv_hb\Scripts\activate

From the hydrobricks directory:

pip install -e .

Test the package:

pip install pytest
# Optionally, install all requirements to test the maximum number of features.
pip install -r python/requirements-optional.txt
pytest ./python/tests/

Build a Python wheel with cibuildwheel

To build hydrobricks wheel, you need:

  • Python 3
  • Docker

If you haven't installed docker, you can install Docker Desktop on Windows, or follow these instructions on Linux (example for Ubuntu):

sudo snap install docker

# Allow your user to user docker (you might need to reboot)
sudo groupadd docker
sudo usermod -aG docker ${USER}

Create a Python virtual environment and activate it

python -m venv ~/venv_hb
source ~/venv_hb/bin/activate

Install cibuildwheel

pip install cibuildwheel

Build hydrobricks for your Python version (python --version). For example, for Python 3.11 under Linux:

cd hydrobricks
cibuildwheel --only cp311-manylinux_x86_64

You can also build it for Windows:

# Selecting the platform
cibuildwheel --platform windows
# Selecting a specific target:
cibuildwheel --only cp38-win_amd64

Build the C++ core only

To build hydrobricks core, you need:

  • A C++ compiler (GCC, Visual Studio)
  • CMake
  • Python 3

Build with CMake

Configure and build (set the desired build type: Debug or Release, for example):

mkdir cmake-build-release
cd cmake-build-release
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release