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 subcommands handling in recent versions of conda #2732

Merged
merged 3 commits into from
Aug 5, 2023
Merged
Changes from 2 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
31 changes: 25 additions & 6 deletions mamba/mamba/mamba.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,15 @@ def clean(args, parser):


def do_call(args, parser):
relative_mod, func_name = args.func.rsplit(".", 1)
if hasattr(args, "func"):
relative_mod, func_name = args.func.rsplit(".", 1)
elif hasattr(args, "_plugin_subcommand"):
relative_mod = f'.{args._plugin_subcommand.action.__module__.split(".")[-1]}'
print(relative_mod)
func_name = args._plugin_subcommand.action.__name__
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
else:
raise ValueError("Unrecognized 'args' object: %r" % args)

# func_name should always be 'execute'
if relative_mod in [
".main_list",
Expand Down Expand Up @@ -873,7 +881,6 @@ def _wrapped_main(*args, **kwargs):
context.__initialized__ = True

init_loggers(context)

result = do_call(parsed_args, p)
exit_code = getattr(
result, "rc", result
Expand Down Expand Up @@ -907,11 +914,23 @@ def main(*args, **kwargs):

args = tuple(ensure_text_type(s) for s in args)

if len(args) > 2 and args[1] == "env" and args[2] in ("create", "update"):
# special handling for conda env create!
from mamba import mamba_env
if len(args) >= 2:
if args[1] == "env":
# special handling for conda env create!
from mamba import mamba_env

return mamba_env.main()
return mamba_env.main()
elif args[1] == "build":
# calling mamba build == conda mambabuild
try:
from boa.cli import mambabuild

return mambabuild.main()
except ImportError as exc:
raise ImportError(
"Please install boa to use mamba build:\n"
" $ mamba install -c conda-forge boa"
) from exc

def exception_converter(*args, **kwargs):
exit_code = 0
Expand Down
Loading