-
Notifications
You must be signed in to change notification settings - Fork 83
/
conda.py
32 lines (26 loc) · 1.29 KB
/
conda.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
""" Planemo specific utilities for dealing with conda, extending Galaxy's
features with planemo specific idioms.
"""
from galaxy.tools.deps import conda_util
from planemo.io import shell
from galaxy.tools.deps.requirements import parse_requirements_from_xml
from galaxy.tools.loader_directory import load_tool_elements_from_path
def build_conda_context(**kwds):
""" Build a Galaxy CondaContext tailored to planemo use
and common command-line arguments.
"""
conda_prefix = kwds.get("conda_prefix", None)
use_planemo_shell = kwds.get("use_planemo_shell_exec", True)
ensure_channels = kwds.get("conda_ensure_channels", "")
shell_exec = shell if use_planemo_shell else None
return conda_util.CondaContext(conda_prefix=conda_prefix,
ensure_channels=ensure_channels,
shell_exec=shell_exec)
def collect_conda_targets(path, found_tool_callback=None, conda_context=None):
conda_targets = []
for (tool_path, tool_xml) in load_tool_elements_from_path(path):
if found_tool_callback:
found_tool_callback(tool_path)
requirements, containers = parse_requirements_from_xml(tool_xml)
conda_targets.extend(conda_util.requirements_to_conda_targets(requirements))
return conda_targets