Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mamba environment option #1370

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions asv/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +3 to +5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be required? (plugins are auto-discovered, failures mean they are dropped from valid options)

10 changes: 9 additions & 1 deletion asv/plugins/mamba.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than explicitly raise from here the current approach is to not let mamba be a valid option for an environment if the import fails.

The reason behind this is to allow for external plugins (it is also why we don't want to have an explicit list of allowed values).

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/source/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +83 to +84
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
but needs a newer Python version (3.8 or greater) and the ``libmambapy``
package must be installed (typically through ``conda``) to provide access to the mamba Python API.

Clarification since libmambapy is not present on PyPI.

See :ref:`environments` for more information.

- ``matrix``: Dependencies you want to preinstall into the environment
Expand Down
Loading