In OGS we make use of Python packages at different stages, e.g.:
Python packages are usually installed via pip
and virtualenv
provides an isolated environment to install these packages to.
We make use of poetry which is a wrapper for pip
and virtualenv
. We recommend to install poetry
with your system package manager or:
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
When configuring with CMake poetry
creates a new virtual environment in the .venv
-directory inside your build directory. It will also install required Python packages into this environment. You can see the current environment definition in the file pyproject.toml
inside your build-directory.
To manually add Python packages run the following inside your build-directory:
poetry add python-package-name # e.g. poetry add numpy
To activate the environment run poetry shell
(this opens a new shell) or for one-off commands run poetry run command
, e.g. poetry run pip list
.
You can also install Conan with Poetry (so you don’t need to install it system-wide) with the CMake-option OGS_USE_CONAN=auto
:
cmake ../ogs -DOGS_USE_CONAN=auto
You can use the argument PYTHON_PACKAGES
on AddTest()
to specifiy additional Python package dependencies.
The following example would install the latest version of numpy
and pandas
version 0.1.2:
AddTest(
...
PYTHON_PACKAGES numpy pandas=0.1.2
...
)
This article was written by Lars Bilke. If you are missing something or you find an error please let us know.
Generated with Hugo 0.79.0. Last revision: December 26, 2020
Commit: [PL/LIE] Subst. MaL::Vector3 by Eigen::Vector3d. d9c9d51c60
| Edit this page on