Пример #1
0
def cli(ctx, path, **kwds):
    """Source output to activate a conda environment for this tool.

        % . <(planemo conda_env bowtie2.xml)
        % which bowtie2
        TODO_PLACE_PATH_HERE
    """
    conda_context = build_conda_context(use_planemo_shell_exec=False, **kwds)
    conda_targets = collect_conda_targets(
        path, conda_context=conda_context
    )
    installed_conda_targets = conda_util.filter_installed_targets(
        conda_targets, conda_context=conda_context
    )
    env_name, exit_code = conda_util.build_isolated_environment(
        installed_conda_targets, conda_context=conda_context
    )
    if exit_code:
        error("Failed to build environmnt for request.")
        return 1

    ps1 = ps1_for_path(path, base="PRE_CONDA_PS1")
    remove_env = "%s env remove -y --name '%s'" % (
        conda_context.conda_exec, env_name
    )
    deactivate = conda_context.deactivate
    activate = conda_context.activate
    command = SOURCE_COMMAND % (
        activate, env_name, ps1,
        deactivate, remove_env
    )
    print(command)
Пример #2
0
def cli(ctx, path, **kwds):
    """Activate a conda environment for tool.

    Source the output of this command to activate a conda environment for this
    tool.

    \b
        $ . <(planemo conda_env seqtk_seq.xml)
        Deactivate environment with conda_env_deactivate
        (seqtk_seq_v6) $ which seqtk
        /home/planemo/miniconda2/envs/jobdepsDkzcjjfecc6d406196737781ff4456ec60975c137e04884e4f4b05dc68192f7cec4656/bin/seqtk
        (seqtk_seq_v6) $ conda_env_deactivate
        $

    """
    conda_context = build_conda_context(ctx,
                                        use_planemo_shell_exec=False,
                                        **kwds)
    conda_targets = collect_conda_targets(ctx, [path])
    installed_conda_targets = conda_util.filter_installed_targets(
        conda_targets, conda_context=conda_context)
    env_name, exit_code = conda_util.build_isolated_environment(
        installed_conda_targets, conda_context=conda_context, quiet=True)
    if exit_code:
        error("Failed to build environment for request.")
        return 1

    ps1 = ps1_for_path(path, base="PRE_CONDA_PS1")
    remove_env = "%s env remove -y --name '%s'" % (conda_context.conda_exec,
                                                   env_name)
    deactivate = conda_context.deactivate
    activate = conda_context.activate
    command = SOURCE_COMMAND % (activate, env_name, ps1, deactivate,
                                remove_env)
    print(command)
def cli(ctx, path, brew=None, skip_install=False, shell=None):
    """List commands to inject brew dependencies.

    Display commands used to modify environment to inject tool's brew
    dependencies.

    \b
        % . <(planemo brew_env bowtie2.xml)
        % which bowtie2
        /home/john/.linuxbrew/Cellar/bowtie2/2.1.0/bin/bowtie2

    By default this will attempt to attempt to install these recipes as needed.
    This automatic installation can be skipped with the ``--skip_install``
    flag.

    Intead of injecting the enviornment into your current shell using the above
    idiom, the ``--shell`` flag can be sent to launch a new subshell when
    sourced.

    \b
        % . <(planemo brew_env --skip_install --shell bowtie2.xml)
        (bowtie2) % which bowtie2
        /home/john/.linuxbrew/Cellar/bowtie2/2.1.0/bin/bowtie2

    """
    tool_xml = load_tool(path)
    mock_args = bunch.Bunch(brew=brew)
    brew_context = brew_exts.BrewContext(mock_args)
    requirements, containers = parse_requirements_from_xml(tool_xml)

    lines = []
    for recipe_context in brew_util.requirements_to_recipe_contexts(
        requirements,
        brew_context
    ):
        if not skip_install:
            brew_exts.versioned_install(recipe_context)
        lines = brew_exts.build_env_statements_from_recipe_context(
            recipe_context
        )
        split_lines = lines.split("\n")
        lines.extend(split_lines)
    if shell:
        # TODO: Would be cool if this wasn't a bunch of random hackery.
        launch_shell = os.environ.get("SHELL")
        if "bash" in launch_shell:
            ps1 = ps1_for_path(path)
            launch_shell = '(source ~/.bashrc; env PS1="%s" %s --norc)' % (
                ps1,
                launch_shell,
            )
        lines.extend([launch_shell])
        print(";".join(lines))
    else:
        print("\n".join(lines))
Пример #4
0
def cli(ctx, path, **kwds):
    """Activate a conda environment for tool.

    Source the output of this command to activate a conda environment for this
    tool.

    \b
        $ . <(planemo conda_env seqtk_seq.xml)
        Deactivate environment with conda_env_deactivate
        (seqtk_seq_v6) $ which seqtk
        /home/planemo/miniconda2/envs/jobdepsDkzcjjfecc6d406196737781ff4456ec60975c137e04884e4f4b05dc68192f7cec4656/bin/seqtk
        (seqtk_seq_v6) $ conda_env_deactivate
        $

    """
    conda_context = build_conda_context(ctx, use_planemo_shell_exec=False, **kwds)
    conda_targets = collect_conda_targets(
        ctx, [path], conda_context=conda_context
    )
    installed_conda_targets = conda_util.filter_installed_targets(
        conda_targets, conda_context=conda_context
    )
    env_name, exit_code = conda_util.build_isolated_environment(
        installed_conda_targets, conda_context=conda_context, quiet=True
    )
    if exit_code:
        error("Failed to build environmnt for request.")
        return 1

    ps1 = ps1_for_path(path, base="PRE_CONDA_PS1")
    remove_env = "%s env remove -y --name '%s'" % (
        conda_context.conda_exec, env_name
    )
    deactivate = conda_context.deactivate
    activate = conda_context.activate
    command = SOURCE_COMMAND % (
        activate, env_name, ps1,
        deactivate, remove_env
    )
    print(command)