Permalink
Browse files

Implement conda_init command.

Building up conda options to match brew options already available.
  • Loading branch information...
jmchilton committed Dec 15, 2015
1 parent e05029f commit ad3b2f0c3cb5e0f669b39b9574f8aa1b1f01a09b
Showing with 65 additions and 0 deletions.
  1. +22 −0 planemo/commands/cmd_conda_init.py
  2. +8 −0 planemo/options.py
  3. +35 −0 planemo_ext/galaxy/tools/deps/conda_util.py
@@ -0,0 +1,22 @@
import click

from planemo.cli import pass_context
from planemo.io import shell
from planmo import options
from galaxy.tools.deps import conda_util


@click.command('conda_init')
@options.conda_prefix_option()
@pass_context
def cli(ctx, conda_prefix=None):
"""Download and install conda.
This will download conda for managing dependencies for your platform
using the appropriate Miniconda installer.
By running this command, you are agreeing to the terms of the conda
license a 3-clause BSD 3 license. Please review full license at
http://docs.continuum.io/anaconda/eula.
"""
conda_util(conda_prefix, shell_exec=shell)
@@ -188,6 +188,14 @@ def brew_option():
)


def conda_prefix_option():
return click.option(
"--conda_prefix",
type=click.Path(file_okay=False, dir_okay=True),
help="Conda prefix to use for conda dependency commands."
)


def required_tool_arg():
""" Decorate click method as requiring the path to a single tool.
"""
@@ -0,0 +1,35 @@
from ..deps import commands
from sys import platform as _platform
import os.path

IS_OS_X = _platform == "darwin"

# BSD 3-clause
CONDA_LICENSE = "http://docs.continuum.io/anaconda/eula"


def conda_link():
if IS_OS_X:
url = "https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh"
else:
url = "https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh"
return url


def find_conda_prefix(conda_prefix=None):
""" If supplied conda_prefix is not set, default to the default location
for Miniconda installs.
"""
if conda_prefix is None:
return os.path.join(os.path.expanduser("~"), "miniconda2")
return conda_prefix


def install_conda_command(prefix, shell_exec=None):
if shell_exec is None:
shell_exec = commands.shell
download_cmd = " ".join(commands.download_command(conda_link(), quote=True))
download_cmd = "%s > /tmp/conda.bash"
install_cmd = "bash /tmp/conda.bash -b -p '%s'" % prefix
full_command = "%s; %s" % (download_cmd, install_cmd)
return shell_exec(full_command)

0 comments on commit ad3b2f0

Please sign in to comment.