Skip to content

Commit

Permalink
Allow conda_install over multiple tool paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Oct 4, 2016
1 parent f0da66f commit 2e4e5fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion planemo/commands/cmd_conda_env.py
Expand Up @@ -46,7 +46,7 @@ def cli(ctx, path, **kwds):
"""
conda_context = build_conda_context(ctx, use_planemo_shell_exec=False, **kwds)
conda_targets = collect_conda_targets(
path, conda_context=conda_context
ctx, path, conda_context=conda_context
)
installed_conda_targets = conda_util.filter_installed_targets(
conda_targets, conda_context=conda_context
Expand Down
6 changes: 3 additions & 3 deletions planemo/commands/cmd_conda_install.py
Expand Up @@ -11,11 +11,11 @@


@click.command('conda_install')
@options.optional_tools_arg()
@options.optional_tools_arg(multiple=True)
@options.conda_target_options()
@options.conda_auto_init_option()
@command_function
def cli(ctx, path, **kwds):
def cli(ctx, paths, **kwds):
"""Install conda packages for tool requirements."""
conda_context = build_conda_context(ctx, **kwds)
if not conda_context.is_conda_installed():
Expand All @@ -36,7 +36,7 @@ def cli(ctx, path, **kwds):
raise ExitCodeException(EXIT_CODE_FAILED_DEPENDENCIES)

return_codes = []
for conda_target in collect_conda_targets(path):
for conda_target in collect_conda_targets(ctx, paths):
ctx.log("Install conda target %s" % conda_target)
return_code = conda_util.install_conda_target(
conda_target, conda_context=conda_context
Expand Down
17 changes: 11 additions & 6 deletions planemo/conda.py
Expand Up @@ -7,9 +7,9 @@
import os

from galaxy.tools.deps import conda_util
from galaxy.tools.loader_directory import load_tool_sources_from_path

from planemo.io import shell
from planemo.tools import yield_tool_sources_on_paths


def build_conda_context(ctx, **kwds):
Expand All @@ -29,13 +29,18 @@ def build_conda_context(ctx, **kwds):
shell_exec=shell_exec)


def collect_conda_targets(path, found_tool_callback=None, conda_context=None):
"""Load CondaTarget objects from supplied artifact sources."""
conda_targets = []
for (tool_path, tool_source) in load_tool_sources_from_path(path):
def collect_conda_targets(ctx, paths, found_tool_callback=None, conda_context=None):
"""Load CondaTarget objects from supplied artifact sources.
If a tool contains more than one requirement, the requirements will each
appear once in the output.
"""
conda_targets = set([])
for (tool_path, tool_source) in yield_tool_sources_on_paths(ctx, paths):
if found_tool_callback:
found_tool_callback(tool_path)
conda_targets.extend(tool_source_conda_targets(tool_source))
for target in tool_source_conda_targets(tool_source):
conda_targets.add(target)
return conda_targets


Expand Down

0 comments on commit 2e4e5fc

Please sign in to comment.