In OGS we make use of Python packages at different stages, e.g.:
Python packages are usually installed via pip inside an isolated environment (a virtual environment). We use a modern alternative to pip: uv.
OGS_USE_PIP=ON CMake option when configuring OGSMake sure that you installed the uv-tool.
When configuring OGS with OGS_USE_PIP=ON uv creates a new virtual environment in the .venv-directory inside your build directory. It will also install required Python packages into this environment. For example, OGSTools or Jupyter will this way be available ready-made in a consistent configuration.
Example usage:
cmake --preset release -DOGS_USE_PIP=ONWhen you want to use the python packages in this virtual environment, you need to activate it by running
cd ../build/release # the build directory
source .envrc # Linux, Mac OR
Invoke-Expression .envrc.ps1 # Windows (PowerShell)where .envrc is a script including source .venv/bin/activate for activating the virtual environment as well as setting some paths. If you have the direnv-tool installed and set up the virtual environment will be activated automatically upon changing into the build directory.
To manually add Python packages run the following inside your build-directory:
uv pip install python-package-nameYou can use the argument PYTHON_PACKAGES on AddTest() to specify 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.147.9
in CI job 683680
|
Last revision: December 20, 2025
Commit: chore: fix spelling mistakes fbc5f730
| Edit this page on