Skip to content

Commit

Permalink
Backport #2878: compatibility fixes for conda 23.9 and conda-libmamba…
Browse files Browse the repository at this point in the history
…-solver 23.9 (#2890)

* trim

* pre-commit

* raise

* require conda 23.9.0+
  • Loading branch information
jaimergp committed Oct 4, 2023
1 parent 0a5ed8d commit a271020
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mamba/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- pybind11-stubgen
- pytest >=7.3
- pyyaml
- conda
- conda >=23.9.0
- conda-content-trust
- cryptography<40.0 # Or breaks conda-content-trust
- pip:
Expand Down
26 changes: 17 additions & 9 deletions mamba/mamba/mamba.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
# create support
from conda.base.constants import ChannelPriority, DepsModifier, UpdateModifier
from conda.base.context import context
from conda.cli.common import (
check_non_admin,
confirm_yn,
ensure_name_or_prefix,
specs_from_url,
)
from conda.cli.common import check_non_admin, confirm_yn, specs_from_url
from conda.cli.install import check_prefix, clone, get_revision
from conda.cli.main import generate_parser, init_loggers
from conda.common.compat import on_win
Expand Down Expand Up @@ -239,8 +234,11 @@ def install(args, parser, command="install"):
solver_task = api.SOLVER_UPDATE
solver_options.clear()

if newenv:
ensure_name_or_prefix(args, command)
if newenv and not (args.name or args.prefix):
raise CondaValueError(
"either -n NAME or -p PREFIX option required,\n"
'try "mamba %s -h" for more details' % command
)
prefix = context.target_prefix
if newenv:
check_prefix(prefix, json=context.json)
Expand Down Expand Up @@ -802,6 +800,16 @@ def configure_parser_repoquery(sub_parsers):
import argparse
from argparse import SUPPRESS

try:
p = sub_parsers.add_parser(
"repoquery", description=descr, help=help_cli, epilog=example
)
except argparse.ArgumentError as exc:
if "conflicting subparser" in str(exc):
# conda-libmamba-solver's repoquery is already registered
return
raise

p = sub_parsers.add_parser(
"repoquery", description=descr, help=help_cli, epilog=example
)
Expand Down Expand Up @@ -880,7 +888,7 @@ def _wrapped_main(*args, **kwargs):
context.__init__(argparse_args=parsed_args)
context.__initialized__ = True

init_loggers(context)
init_loggers()
result = do_call(parsed_args, p)
exit_code = getattr(
result, "rc", result
Expand Down

0 comments on commit a271020

Please sign in to comment.