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

changes for mamba 2.0 #1439

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
32 changes: 26 additions & 6 deletions asv/plugins/mamba.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from yaml import Loader

import libmambapy

from ._mamba_helpers import MambaSolver
from .. import environment, util
from ..console import log

Expand Down Expand Up @@ -81,6 +79,7 @@ def __init__(self, conf, python, requirements, tagged_env_vars):
with mambarc_path.open() as f:
condarc_data = yaml.safe_load(f)
self._apply_condarc_settings(condarc_data)
self.channel_context = libmambapy.ChannelContext.make_conda_compatible(self.context)

def _apply_condarc_settings(self, condarc_data):
# Apply channel settings
Expand Down Expand Up @@ -149,12 +148,33 @@ def _setup(self):
except KeyError:
raise KeyError("Only pip is supported as a secondary key")
mamba_pkgs += mamba_args
solver = MambaSolver(
self._mamba_channels, None, self.context # or target_platform
Request = libmambapy.solver.Request
MatchSpec = libmambapy.specs.MatchSpec
request = Request(
jobs=[
Request.Install(MatchSpec.parse(pkg)) for pkg in mamba_pkgs
],
)
solver = libmambapy.solver.libsolv.Solver()
ChannelResolveParams = libmambapy.specs.ChannelResolveParams
channels = [self.channel_context.make_channel(chan) for chan in self._mamba_channels]
channel_map = ChannelResolveParams.ChannelMap(dict((text_chan, chan[0]) for (text_chan, chan) in zip(self._mamba_channels, channels)))
db = libmambapy.solver.libsolv.Database(
ChannelResolveParams(custom_channels=channel_map)
)
### seemingly working up to here. But how to perform actions?
with _mamba_lock():
transaction = solver.solve(mamba_pkgs)
transaction.execute(libmambapy.PrefixData(self._path))
outcome = solver.solve(db, request)
Solution = libmambapy.solver.Solution
# libmambapy.PrefixData(self._path)
if isinstance(outcome, Solution):
for action in outcome.actions:
if isinstance(action, Solution.Upgrade):
...
if isinstance(action, Solution.Reinstall):
...
...

if pip_args:
for declaration in pip_args:
parsed_declaration = util.ParsedPipDeclaration(declaration)
Expand Down
2 changes: 1 addition & 1 deletion test/test_environment_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_asv_benchmark(asv_project_factory, env):
)
@pytest.mark.skipif(not tools.HAS_MAMBA,
reason="needs mamba")
def test_asv_mamba(
def test_asv_mamba_f(
asv_project_factory, config_modifier, expected_success, expected_error
):
"""
Expand Down
Loading