Skip to content

Commit ca19910

Browse files
committed
Allow conda_install to take in --conda_auto_init.
1 parent 07d94bd commit ca19910

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

planemo/commands/cmd_conda_install.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,35 @@
66
from planemo import options
77
from planemo.cli import command_function
88
from planemo.conda import build_conda_context, collect_conda_targets
9-
from planemo.io import coalesce_return_codes
9+
from planemo.exit_codes import EXIT_CODE_FAILED_DEPENDENCIES, ExitCodeException
10+
from planemo.io import coalesce_return_codes, error
1011

1112

1213
@click.command('conda_install')
1314
@options.optional_tools_arg()
1415
@options.conda_target_options()
16+
@options.conda_auto_init_option()
1517
@command_function
1618
def cli(ctx, path, **kwds):
1719
"""Install conda packages for tool requirements."""
1820
conda_context = build_conda_context(ctx, **kwds)
21+
if not conda_context.is_conda_installed():
22+
auto_init = kwds.get("conda_auto_init", False)
23+
failed = True
24+
if auto_init:
25+
if conda_context.can_install_conda():
26+
if conda_util.install_conda(conda_context):
27+
error("Attempted to install conda and failed.")
28+
else:
29+
failed = False
30+
else:
31+
error("Cannot install conda, failing conda_install.")
32+
else:
33+
error("Conda not configured - run planemo conda_init' or pass --conda_auto_init to continue.")
34+
35+
if failed:
36+
raise ExitCodeException(EXIT_CODE_FAILED_DEPENDENCIES)
37+
1938
return_codes = []
2039
for conda_target in collect_conda_targets(path):
2140
ctx.log("Install conda target %s" % conda_target)

planemo/exit_codes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# An unsupported file type was supplied for a given operation.
1616
EXIT_CODE_UNSUPPORTED_FILE_TYPE = 5
1717

18+
# A dependency of this operation was unavailable (e.g. conda).
19+
EXIT_CODE_FAILED_DEPENDENCIES = 6
20+
1821

1922
class ExitCodeException(Exception):
2023
"""Exception used by planemo framework to track exit codes for CLI."""

0 commit comments

Comments
 (0)