示例#1
0
def r_library_installer(config):
    """Install R libraries using CRAN and Bioconductor.
    """
    if config.get("cran") or config.get("bioc") or config.get("github"):
        with shared._make_tmp_dir() as tmp_dir:
            with cd(tmp_dir):
                # Create an Rscript file with install details.
                out_file = os.path.join(tmp_dir, "install_packages.R")
                _make_install_script(out_file, config)
                # run the script and then get rid of it
                # try using either
                rlib_installed = False
                rscripts = []
                conda_bin = shared._conda_cmd(env)
                if conda_bin:
                    rscripts.append(
                        fabutils.find_cmd(
                            env,
                            os.path.join(os.path.dirname(conda_bin),
                                         "Rscript"), "--version"))
                rscripts.append(fabutils.find_cmd(env, "Rscript", "--version"))
                for rscript in rscripts:
                    if rscript:
                        env.safe_run("%s %s" % (rscript, out_file))
                        rlib_installed = True
                        break
                if not rlib_installed:
                    env.logger.warn(
                        "Rscript not found; skipping install of R libraries.")
                env.safe_run("rm -f %s" % out_file)
示例#2
0
def r_library_installer(config):
    """Install R libraries using CRAN and Bioconductor.
    """
    if config.get("cran") or config.get("bioc") or config.get("github"):
        with shared._make_tmp_dir() as tmp_dir:
            with cd(tmp_dir):
                # Create an Rscript file with install details.
                out_file = os.path.join(tmp_dir, "install_packages.R")
                _make_install_script(out_file, config)
                # run the script and then get rid of it
                # try using either
                rlib_installed = False
                rscripts = []
                conda_bin = shared._conda_cmd(env)
                if conda_bin:
                    rscripts.append(fabutils.find_cmd(env, os.path.join(os.path.dirname(conda_bin), "Rscript"),
                                                    "--version"))
                rscripts.append(fabutils.find_cmd(env, "Rscript", "--version"))
                for rscript in rscripts:
                    if rscript:
                        env.safe_run("%s %s" % (rscript, out_file))
                        rlib_installed = True
                        break
                if not rlib_installed:
                    env.logger.warn("Rscript not found; skipping install of R libraries.")
                env.safe_run("rm -f %s" % out_file)
示例#3
0
def _brew_cmd(env):
    """Retrieve brew command for installing homebrew packages.
    """
    cmd = find_cmd(env, "brew", "--version")
    if cmd is None:
        raise ValueError("Did not find working installation of Linuxbrew/Homebrew")
    else:
        return cmd
示例#4
0
def _brew_cmd(env):
    """Retrieve brew command for installing homebrew packages.
    """
    cmd = find_cmd(env, "brew", "--version")
    if cmd is None:
        raise ValueError(
            "Did not find working installation of Linuxbrew/Homebrew")
    else:
        return cmd
示例#5
0
def install_packages(env):
    config_file = get_config_file(env, "perl-libs.yaml")
    (packages, _) = _yaml_to_packages(config_file.base, subs_yaml_file=config_file.dist, namesort=False)
    cpanm_cmd = find_cmd(env, "cpanm", "--version")
    for package in packages:
        if package.count("==") > 1:
            _install_from_url(env, cpanm_cmd, package)
        else:
            _install_from_cpan(env, cpanm_cmd, package)
示例#6
0
def r_library_installer(config):
    """Install R libraries using CRAN and Bioconductor.
    """
    # Create an Rscript file with install details.
    out_file = "install_packages.R"
    if env.safe_exists(out_file):
        env.safe_run("rm -f %s" % out_file)
    env.safe_run("touch %s" % out_file)
    lib_loc = os.path.join(env.system_install, "lib", "R", "site-library")
    env.safe_sudo("mkdir -p %s" % lib_loc)
    repo_info = """
    .libPaths(c("%s"))
    library(methods)
    cran.repos <- getOption("repos")
    cran.repos["CRAN" ] <- "%s"
    options(repos=cran.repos)
    source("%s")
    """ % (lib_loc, config["cranrepo"], config["biocrepo"])
    env.safe_append(out_file, repo_info)
    install_fn = """
    repo.installer <- function(repos, install.fn) {
      %s
      maybe.install <- function(pname) {
        if (!(pname %%in%% installed.packages()))
          install.fn(pname)
      }
    }
    """
    if config.get("update_packages", True):
        update_str = """
        update.packages(lib.loc="%s", repos=repos, ask=FALSE)
        """ % lib_loc
    else:
        update_str = "\n"
    env.safe_append(out_file, install_fn % update_str)
    std_install = """
    std.pkgs <- c(%s)
    std.installer = repo.installer(cran.repos, install.packages)
    lapply(std.pkgs, std.installer)
    """ % (", ".join('"%s"' % p for p in config['cran']))
    env.safe_append(out_file, std_install)
    if len(config.get("bioc", [])) > 0:
        bioc_install = """
        bioc.pkgs <- c(%s)
        bioc.installer = repo.installer(biocinstallRepos(), biocLite)
        lapply(bioc.pkgs, bioc.installer)
        """ % (", ".join('"%s"' % p for p in config['bioc']))
        env.safe_append(out_file, bioc_install)
    # run the script and then get rid of it
    rscript = fabutils.find_cmd(env, "Rscript", "--version")
    if rscript:
        env.safe_sudo("%s %s" % (rscript, out_file))
    else:
        env.logger.warn("Rscript not found; skipping install of R libraries.")
    env.safe_run("rm -f %s" % out_file)
示例#7
0
def r_library_installer(config):
    """Install R libraries using CRAN and Bioconductor.
    """
    # Create an Rscript file with install details.
    out_file = "install_packages.R"
    if env.safe_exists(out_file):
        env.safe_run("rm -f %s" % out_file)
    env.safe_run("touch %s" % out_file)
    lib_loc = os.path.join(env.system_install, "lib", "R", "site-library")
    env.safe_sudo("mkdir -p %s" % lib_loc)
    repo_info = """
    .libPaths(c("%s"))
    library(methods)
    cran.repos <- getOption("repos")
    cran.repos["CRAN" ] <- "%s"
    options(repos=cran.repos)
    source("%s")
    """ % (lib_loc, config["cranrepo"], config["biocrepo"])
    env.safe_append(out_file, repo_info)
    install_fn = """
    repo.installer <- function(repos, install.fn) {
      %s
      maybe.install <- function(pname) {
        if (!(pname %%in%% installed.packages()))
          install.fn(pname)
      }
    }
    """
    if config.get("update_packages", True):
        update_str = """
        update.packages(lib.loc="%s", repos=repos, ask=FALSE)
        """ % lib_loc
    else:
        update_str = "\n"
    env.safe_append(out_file, install_fn % update_str)
    std_install = """
    std.pkgs <- c(%s)
    std.installer = repo.installer(cran.repos, install.packages)
    lapply(std.pkgs, std.installer)
    """ % (", ".join('"%s"' % p for p in config['cran']))
    env.safe_append(out_file, std_install)
    if len(config.get("bioc", [])) > 0:
        bioc_install = """
        bioc.pkgs <- c(%s)
        bioc.installer = repo.installer(biocinstallRepos(), biocLite)
        lapply(bioc.pkgs, bioc.installer)
        """ % (", ".join('"%s"' % p for p in config['bioc']))
        env.safe_append(out_file, bioc_install)
    # run the script and then get rid of it
    rscript = fabutils.find_cmd(env, "Rscript", "--version")
    if rscript:
        env.safe_sudo("%s %s" % (rscript, out_file))
    else:
        env.logger.warn("Rscript not found; skipping install of R libraries.")
    env.safe_run("rm -f %s" % out_file)
示例#8
0
def r_library_installer(config):
    """Install R libraries using CRAN and Bioconductor.
    """
    with shared._make_tmp_dir() as tmp_dir:
        with cd(tmp_dir):
            # Create an Rscript file with install details.
            out_file = os.path.join(tmp_dir, "install_packages.R")
            _make_install_script(out_file, config)
            # run the script and then get rid of it
            rscript = fabutils.find_cmd(env, "Rscript", "--version")
            if rscript:
                env.safe_run("%s %s" % (rscript, out_file))
            else:
                env.logger.warn("Rscript not found; skipping install of R libraries.")
            env.safe_run("rm -f %s" % out_file)
示例#9
0
def r_library_installer(config):
    """Install R libraries using CRAN and Bioconductor.
    """
    with shared._make_tmp_dir() as tmp_dir:
        with cd(tmp_dir):
            # Create an Rscript file with install details.
            out_file = os.path.join(tmp_dir, "install_packages.R")
            _make_install_script(out_file, config)
            # run the script and then get rid of it
            rscript = fabutils.find_cmd(env, "Rscript", "--version")
            if rscript:
                env.safe_run("%s %s" % (rscript, out_file))
            else:
                env.logger.warn(
                    "Rscript not found; skipping install of R libraries.")
            env.safe_run("rm -f %s" % out_file)