|
6 | 6 | from planemo import options
|
7 | 7 | from planemo.cli import command_function
|
8 | 8 | 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 |
10 | 11 |
|
11 | 12 |
|
12 | 13 | @click.command('conda_install')
|
13 | 14 | @options.optional_tools_arg()
|
14 | 15 | @options.conda_target_options()
|
| 16 | +@options.conda_auto_init_option() |
15 | 17 | @command_function
|
16 | 18 | def cli(ctx, path, **kwds):
|
17 | 19 | """Install conda packages for tool requirements."""
|
18 | 20 | 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 | + |
19 | 38 | return_codes = []
|
20 | 39 | for conda_target in collect_conda_targets(path):
|
21 | 40 | ctx.log("Install conda target %s" % conda_target)
|
|
0 commit comments