DunePythonFindPackage

Helpers for checking whether Python packages are available for a given interpreter.

dune_python_find_package

Check whether a Python package can be imported and optionally whether it satisfies a version constraint.

dune_python_find_package(
  PACKAGE <package>
  [RESULT <var>]
  [REQUIRED]
  [VERSION <version>]
  [EXACT]
  [INTERPRETER <python>]
)
PACKAGE

Name of the Python package to look for.

RESULT

Variable that receives the result in the calling scope. If omitted, the default is DUNE_PYTHON_<package>_FOUND. The package name is case sensitive and is typically lowercase.

REQUIRED

If given, configuration fails when the package cannot be found.

VERSION

Minimum version required for the package.

EXACT

Require the version given by VERSION to match exactly.

INTERPRETER

Python interpreter whose search path is used. The default is Python3::Interpreter. This can differ from the system interpreter when using DUNE’s configure-time virtual environment.

The package check is performed by importing the module with the selected interpreter. If the import succeeds, the package version is queried through the dune-common helper script pyversion.py.