diff --git a/asv/plugins/__init__.py b/asv/plugins/__init__.py index 9dce85d06..3a3064398 100644 --- a/asv/plugins/__init__.py +++ b/asv/plugins/__init__.py @@ -1 +1,5 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst + +# Import to make sure plugins are discoverable +import asv.plugins.conda +import asv.plugins.mamba diff --git a/asv/plugins/mamba.py b/asv/plugins/mamba.py index d3728a866..1aa9c82c3 100644 --- a/asv/plugins/mamba.py +++ b/asv/plugins/mamba.py @@ -11,7 +11,13 @@ except ImportError: from yaml import Loader -from mamba.api import libmambapy, MambaSolver +try: + from mamba.api import MambaSolver + import libmambapy + _HAS_LIBMAMBAPY = True +except ImportError: + _HAS_LIBMAMBAPY = False + from .. import environment, util from ..console import log @@ -51,6 +57,8 @@ def __init__(self, conf, python, requirements, tagged_env_vars): Dictionary mapping a PyPI package name to a version identifier string. """ + if not _HAS_LIBMAMBAPY: + raise ImportError("Failed to import 'libmambapy' Python module.") self._python = python self._requirements = requirements self._mamba_channels = conf.conda_channels diff --git a/docs/source/using.rst b/docs/source/using.rst index faf445776..420b70271 100644 --- a/docs/source/using.rst +++ b/docs/source/using.rst @@ -80,7 +80,8 @@ suite are: - ``environment_type``: The tool used to create environments. May be ``conda`` or ``virtualenv`` or ``mamba``. If Conda supports the dependencies you need, that is the recommended method. Mamba is faster - but needs a newer Python version (3.8 or greater). + but needs a newer Python version (3.8 or greater) and the ``libmambapy`` + package must be installed to provide access to the mamba Python API. See :ref:`environments` for more information. - ``matrix``: Dependencies you want to preinstall into the environment