Specify Python interpreter path or version when calling CMake

Summary

dune-common uses findPythonInterp.cmake to find a Python interpreter on the system and offers the function dune_python_require_version to abort if the found interpreter doesn't match a specific version requirement. However, there is no way of specifying a certain Python interpreter if there are multiple ones installed on a system.

Is there way to set the Python interpreter explicitly?

Set Python interpreter through CMake variables

When building a virtual environment, it is necessary that the Python interpreter is specified for the dune-common module. I'm thinking of CMake variables like

  • PYTHON_PATH to the interpreter, or
  • PYTHON_VERSION specifying the exact version to be used

Use case

  1. Use Ubuntu 16.04 LTS (Python3.5 included)
  2. Have a DUNE module that uses the dune-venv and requires Python3.6
  3. Install Python3.6 separately
  4. dune-common always uses the v3.5 interpreter
  5. Installation of my module fails