Installation
Linux/MacOS
Prerequisites
git
Python 3.11 or higher
Clone the repository and recursively update submodules:
git clone git@github.com:leap-c/leap-c.git leap_c
cd leap_c
git submodule update --init --recursive
Python
We work with Python 3.11. If it is not already installed on your system, you can obtain it using deadsnakes:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.11
A virtual environment is recommended. For example, to create a virtual environment called .venv
and activate it, run:
pip3 install virtualenv
virtualenv --python=/usr/bin/python3.11 .venv
source .venv/bin/activate
The following steps assume that the virtual environment is activated.
CasADi
Install CasADi by running:
pip install casadi
acados
Then change into the acados directory
cd external/acados
and build it as described in the acados documentation. When running the
cmake
command, make sure to include the options -DACADOS_WITH_OPENMP=ON
, -DACADOS_PYTHON=ON
and -DACADOS_NUM_THREADS=1
.
PyTorch
Install PyTorch as described on the PyTorch website.
To install CPU-only PyTorch you can use:
pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
Install leap-c
To install the package in the root directory of the repository, run:
pip install -e .
For development, you might want to install additional dependencies:
pip install -e .[dev]
See the pyproject.toml for more information on the installed packages.
Testing
To run the tests, use:
pytest tests -vv -s
Linting and Formatting
Only relevant if you want to contribute to the repository. For keeping our code style and our diffs consistent we use the Ruff linter and formatter (so far we use the standard settings).
To make this as easy as possible we also provide a pre-commit config for running the linter and formatter automatically at every commit. For enabling pre-commit follow these steps:
Install pre-commit using pip (already done if you installed the additional “[dev]” dependencies of leap-c).
pip install pre-commit
In the leap-c root directory run
pre-commit install
Done! Now every commit will automatically be linted and formatted.