Skip to content

Commit 07d94bd

Browse files
committed
Overhaul Conda support for recent Galaxy improvements.
Always set a condarc file up when using planemo - this is needed to fix channel handling for galaxy-lib update which sets up a $HOME for every conda command. Also update the list of default channels.
1 parent b93d9dd commit 07d94bd

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed

planemo/commands/cmd_conda_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def cli(ctx, path, **kwds):
4343
% which bowtie2
4444
TODO_PLACE_PATH_HERE
4545
"""
46-
conda_context = build_conda_context(use_planemo_shell_exec=False, **kwds)
46+
conda_context = build_conda_context(ctx, use_planemo_shell_exec=False, **kwds)
4747
conda_targets = collect_conda_targets(
4848
path, conda_context=conda_context
4949
)

planemo/commands/cmd_conda_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ def cli(ctx, **kwds):
2121
license a 3-clause BSD 3 license. Please review full license at
2222
http://docs.continuum.io/anaconda/eula.
2323
"""
24-
conda_context = build_conda_context(**kwds)
24+
conda_context = build_conda_context(ctx, **kwds)
2525
return conda_util.install_conda(conda_context=conda_context)

planemo/commands/cmd_conda_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@command_function
1616
def cli(ctx, path, **kwds):
1717
"""Install conda packages for tool requirements."""
18-
conda_context = build_conda_context(**kwds)
18+
conda_context = build_conda_context(ctx, **kwds)
1919
return_codes = []
2020
for conda_target in collect_conda_targets(path):
2121
ctx.log("Install conda target %s" % conda_target)

planemo/conda.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
""" Planemo specific utilities for dealing with conda, extending Galaxy's
2-
features with planemo specific idioms.
1+
"""Planemo specific utilities for dealing with conda.
2+
3+
The extend Galaxy/galaxy-lib's features with planemo specific idioms.
34
"""
45
from __future__ import absolute_import
56

7+
import os
8+
69
from galaxy.tools.deps import conda_util
710
from galaxy.tools.deps.requirements import parse_requirements_from_xml
811
from galaxy.tools.loader_directory import load_tool_elements_from_path
912

1013
from planemo.io import shell
1114

1215

13-
def build_conda_context(**kwds):
14-
""" Build a Galaxy CondaContext tailored to planemo use
15-
and common command-line arguments.
16+
def build_conda_context(ctx, **kwds):
17+
"""Build a galaxy-lib CondaContext tailored to planemo use.
18+
19+
Using planemo's common command-line/globa config options.
1620
"""
21+
condarc_override_default = os.path.join(ctx.workspace, "condarc")
1722
conda_prefix = kwds.get("conda_prefix", None)
1823
use_planemo_shell = kwds.get("use_planemo_shell_exec", True)
1924
ensure_channels = kwds.get("conda_ensure_channels", "")
25+
condarc_override = kwds.get("condarc", condarc_override_default)
2026
shell_exec = shell if use_planemo_shell else None
2127
return conda_util.CondaContext(conda_prefix=conda_prefix,
2228
ensure_channels=ensure_channels,
29+
condarc_override=condarc_override,
2330
shell_exec=shell_exec)
2431

2532

2633
def collect_conda_targets(path, found_tool_callback=None, conda_context=None):
34+
"""Load CondaTarget objects from supplied artifact sources."""
2735
conda_targets = []
2836
for (tool_path, tool_xml) in load_tool_elements_from_path(path):
2937
if found_tool_callback:

planemo/galaxy/config.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def docker_galaxy_config(ctx, runnables, for_tests=False, **kwds):
180180
def config_join(*args):
181181
return os.path.join(config_directory, *args)
182182

183-
_handle_dependency_resolution(config_directory, kwds)
183+
_handle_dependency_resolution(ctx, config_directory, kwds)
184184
_handle_job_metrics(config_directory, kwds)
185185

186186
shed_tool_conf = "config/shed_tool_conf.xml"
@@ -289,7 +289,7 @@ def config_join(*args):
289289
galaxy_root = config_join("galaxy-dev")
290290

291291
server_name = "planemo%d" % random.randint(0, 100000)
292-
_handle_dependency_resolution(config_directory, kwds)
292+
_handle_dependency_resolution(ctx, config_directory, kwds)
293293
_handle_job_config_file(config_directory, server_name, kwds)
294294
_handle_job_metrics(config_directory, kwds)
295295
file_path = kwds.get("file_path") or config_join("files")
@@ -1118,7 +1118,7 @@ def _handle_job_config_file(config_directory, server_name, kwds):
11181118
kwds["job_config_file"] = job_config_file
11191119

11201120

1121-
def _handle_dependency_resolution(config_directory, kwds):
1121+
def _handle_dependency_resolution(ctx, config_directory, kwds):
11221122
resolutions_strategies = [
11231123
"brew_dependency_resolution",
11241124
"dependency_resolvers_config_file",
@@ -1149,16 +1149,19 @@ def _handle_dependency_resolution(config_directory, kwds):
11491149
def add_attribute(key, value):
11501150
attributes.append('%s="%s"' % (key, value))
11511151

1152+
conda_prefix_specified = False
11521153
for key, default_value in iteritems(dependency_attribute_kwds):
11531154
value = kwds.get(key, default_value)
11541155
if value != default_value:
1156+
conda_prefix_specified = value == "conda_prefix"
11551157
# Strip leading prefix (conda_) off attributes
11561158
attribute_key = "_".join(key.split("_")[1:])
11571159
add_attribute(attribute_key, value)
11581160

1159-
if not [attribute for attribute in attributes if "prefix" in attribute]:
1160-
conda_context = build_conda_context(**kwds)
1161+
conda_context = build_conda_context(ctx, **kwds)
1162+
if not conda_prefix_specified:
11611163
add_attribute("prefix", conda_context.conda_prefix)
1164+
add_attribute("condarc_override", conda_context.condarc_override)
11621165

11631166
attribute_str = " ".join(attributes)
11641167

@@ -1173,6 +1176,11 @@ def add_attribute(key, value):
11731176
'attributes': attribute_str
11741177
})
11751178
open(resolvers_conf, "w").write(conf_contents)
1179+
ctx.vlog(
1180+
"Writing dependency_resolvers_config_file to path %s with contents [%s]",
1181+
resolvers_conf,
1182+
conf_contents,
1183+
)
11761184
kwds["dependency_resolvers_config_file"] = resolvers_conf
11771185

11781186

planemo/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def conda_ensure_channels_option():
432432
use_global_config=True,
433433
help=("Ensure conda is configured with specified comma separated "
434434
"list of channels."),
435-
default="r,bioconda"
435+
default="r,bioconda,iuc",
436436
)
437437

438438

0 commit comments

Comments
 (0)