Browse files

Allow ``conda_install`` to work with packages as well as just tools.

  • Loading branch information...
jmchilton committed Feb 16, 2017
1 parent 9c790d0 commit 8faf661f70204ddd48945d583bcd95613a58ed0b
Showing with 53 additions and 3 deletions.
  1. +3 −2 planemo/commands/
  2. +24 −1 planemo/
  3. +26 −0 planemo/
@@ -10,8 +10,9 @@

def cli(ctx, paths, **kwds):
@@ -21,7 +22,7 @@ def cli(ctx, paths, **kwds):
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
conda_target, conda_context=conda_context, skip_environment=kwds.get("global", False)
return coalesce_return_codes(return_codes, assert_at_least_one=True)
@@ -60,14 +60,37 @@ def collect_conda_targets(ctx, paths, found_tool_callback=None, conda_context=No
appear once in the output.
conda_targets = set([])
for (tool_path, tool_source) in yield_tool_sources_on_paths(ctx, paths):
real_paths = []
for path in paths:
if not os.path.exists(path):
targets = target_str_to_targets(path)
[conda_targets.add(_) for _ in targets]

for (tool_path, tool_source) in yield_tool_sources_on_paths(ctx, real_paths):
if found_tool_callback:
for target in tool_source_conda_targets(tool_source):
return conda_targets

# Copied and modified from mulled stuff - need to syncronize these concepts.
def target_str_to_targets(targets_raw):
def parse_target(target_str):
if "=" in target_str:
package_name, version = target_str.split("=", 1)
package_name = target_str
version = None
target = conda_util.CondaTarget(package_name, version)
return target

targets = [parse_target(_) for _ in targets_raw.split(",")]
return targets

def collect_conda_target_lists(ctx, paths, found_tool_callback=None):
"""Load CondaTarget lists from supplied artifact sources.
@@ -481,6 +481,18 @@ def conda_auto_init_option():

def conda_global_option():
return planemo_option(
help=("Install Conda dependencies globally instead of in requirement specific "
"environments packaged for tools. If the Conda bin directory is on your "
"PATH, tools may still use binaries but this is more designed for "
"interactive testing and debugging.")

def required_tool_arg():
""" Decorate click method as requiring the path to a single tool.
@@ -514,6 +526,20 @@ def _optional_tools_default(ctx, param, value):
return value

def optional_tools_or_packages_arg(multiple=False):
""" Decorate click method as optionally taking in the path to a tool
or directory of tools or a Conda package. If no such argument is given
the current working directory will be treated as a directory of tools.
name = "paths" if multiple else "path"
nargs = -1 if multiple else 1
return click.argument(

def optional_tools_arg(multiple=False):
""" Decorate click method as optionally taking in the path to a tool
or directory of tools. If no such argument is given the current working

0 comments on commit 8faf661

Please sign in to comment.