Skip to content

[Python] Check if found DUNE_PYTHON_VIRTUALENV_PATH is writeable

During the configuration time of a module dune-foo Cmake is searching for an existing Python virtual env. One is found using https://gitlab.dune-project.org/core/dune-common/-/blob/master/cmake/modules/DunePythonVirtualenv.cmake#L116, e.g. in /somewhere/dune/dune-common/build-cmake/dune-env. This is used for the rest of https://gitlab.dune-project.org/core/dune-common/-/blob/master/cmake/modules/DunePythonVirtualenv.cmake. This fails for me when this directory DUNE_PYTHON_VIRTUALENV_PATH is not writeable by the current user.

In this MR I add a check, if the found DUNE_PYTHON_VIRTUALENV_PATHis actually writeable. Maybe there is a more elegant way to check this. If this check fails, a reasonable fallback is to locally build a venv in dune-foo, which automatically happens, if DUNE_PYTHON_VIRTUALENV_PATH is unset. Thus, the behaviour of finding a non writeable directory is the same as finding no directory at all.

It is maybe also interesting to add a switch instead to force the local build of a venv.

Instead of unset the variable, we can throw an Cmake error like "Found dune-commom venv path is not writeable. Allow local venv generation with DUNE_FORCE_LOCAL_VENV=true"

Edited by Alexander Müller

Merge request reports