Skip to content

Commit

Permalink
Pass ncpus to install.packages.
Browse files Browse the repository at this point in the history
Manual merge. Closes #401.
  • Loading branch information
hadley committed Mar 24, 2014
1 parent ed715dd commit df94ccc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
6 changes: 5 additions & 1 deletion NEWS.md
@@ -1,5 +1,9 @@
# devtools 1.4.1.99

* `install()` gains `thread` argument which allows you to install multiple
packages in parallel (@mllg, #401). `threads` argument to `check_cran()`
now defaults to `getOption("Ncpus")`

* `install_github()` now prefers personal access tokens supplied to
`auth_token` rather than passwords (#418, @jeroenooms).

Expand All @@ -20,7 +24,7 @@
* `release()` does a better job of opening your email client if you're inside
of Rstudio (#433).

* `build_win()` now builds R-release and R-devel by default.
* `build_win()` now builds R-release and R-devel by default.
(Thanks to @krlmlr, #438)

* The `with_options()` function works as expected, used to throw an error when
Expand Down
3 changes: 2 additions & 1 deletion R/check-cran.r
Expand Up @@ -18,6 +18,7 @@
#' @param bioconductor include bioconductor packages in checking?
#' @param type binary package type of test
#' @param threads number of concurrent threads to use for checking.
#' It defaults to the option \code{"Ncpus"} or \code{1} if unset.
#' @param check_dir the directory in which the package is checked
#' @return invisible \code{TRUE} if successful and no ERRORs or WARNINGS,
#' @importFrom tools package_dependencies
Expand All @@ -32,7 +33,7 @@
#' }
check_cran <- function(pkgs, libpath = file.path(tempdir(), "R-lib"),
srcpath = libpath, bioconductor = FALSE, type = getOption("pkgType"),
threads = 1, check_dir = tempfile("check_cran")) {
threads = getOption("Ncpus", 1), check_dir = tempfile("check_cran")) {
stopifnot(is.character(pkgs))
if (length(pkgs) == 0) return()

Expand Down
13 changes: 9 additions & 4 deletions R/install.r
Expand Up @@ -38,6 +38,9 @@
#' @param keep_source If \code{TRUE} will keep the srcrefs from an installed
#' package. This is useful for debugging (especially inside of RStudio).
#' It defaults to the option \code{"keep.source.pkgs"}.
#' @param threads number of concurrent threads to use for installing
#' dependencies.
#' It defaults to the option \code{"Ncpus"} or \code{1} if unset.
#' @export
#' @family package installation
#' @seealso \code{\link{with_debug}} to install packages with debugging flags
Expand All @@ -46,12 +49,13 @@
install <- function(pkg = ".", reload = TRUE, quick = FALSE, local = TRUE,
args = getOption("devtools.install.args"), quiet = FALSE,
dependencies = NA, build_vignettes = !quick,
keep_source = getOption("keep.source.pkgs")) {
keep_source = getOption("keep.source.pkgs"),
threads = getOption("Ncpus", 1)) {

pkg <- as.package(pkg)

if (!quiet) message("Installing ", pkg$package)
install_deps(pkg, dependencies = dependencies)
install_deps(pkg, dependencies = dependencies, threads = threads)

# Build the package. Only build locally if it doesn't have vignettes
has_vignettes <- length(pkgVignettes(dir = pkg$path)$doc > 0)
Expand Down Expand Up @@ -85,7 +89,8 @@ install <- function(pkg = ".", reload = TRUE, quick = FALSE, local = TRUE,
#' @export
#' @examples
#' \dontrun{install_deps(".")}
install_deps <- function(pkg = ".", dependencies = NA) {
install_deps <- function(pkg = ".", dependencies = NA,
threads = getOption("Ncpus", 1)) {
pkg <- as.package(pkg)
info <- pkg_deps(pkg, dependencies)

Expand All @@ -103,7 +108,7 @@ install_deps <- function(pkg = ".", dependencies = NA) {

message("Installing dependencies for ", pkg$package, ":\n",
paste(deps, collapse = ", "))
install.packages(deps, dependencies = NA)
install.packages(deps, dependencies = NA, Ncpus = threads)
invisible(deps)
}

Expand Down
7 changes: 4 additions & 3 deletions man/check_cran.Rd
Expand Up @@ -4,8 +4,8 @@
\title{Check a package from CRAN.}
\usage{
check_cran(pkgs, libpath = file.path(tempdir(), "R-lib"), srcpath = libpath,
bioconductor = FALSE, type = getOption("pkgType"), threads = 1,
check_dir = tempfile("check_cran"))
bioconductor = FALSE, type = getOption("pkgType"),
threads = getOption("Ncpus", 1), check_dir = tempfile("check_cran"))
}
\arguments{
\item{pkgs}{Vector of package names - note that unlike other \pkg{devtools}
Expand All @@ -23,7 +23,8 @@ redownload the packages every time you run the package.}

\item{type}{binary package type of test}

\item{threads}{number of concurrent threads to use for checking.}
\item{threads}{number of concurrent threads to use for checking.
It defaults to the option \code{"Ncpus"} or \code{1} if unset.}

\item{check_dir}{the directory in which the package is checked}
}
Expand Down
7 changes: 6 additions & 1 deletion man/install.Rd
Expand Up @@ -6,7 +6,8 @@
install(pkg = ".", reload = TRUE, quick = FALSE, local = TRUE,
args = getOption("devtools.install.args"), quiet = FALSE,
dependencies = NA, build_vignettes = !quick,
keep_source = getOption("keep.source.pkgs"))
keep_source = getOption("keep.source.pkgs"), threads = getOptions("Ncpus",
1))
}
\arguments{
\item{pkg}{package description, can be path or package name. See
Expand Down Expand Up @@ -42,6 +43,10 @@ sure vignettes are built even if a build never happens (i.e. because
\item{keep_source}{If \code{TRUE} will keep the srcrefs from an installed
package. This is useful for debugging (especially inside of RStudio).
It defaults to the option \code{"keep.source.pkgs"}.}
\item{threads}{number of concurrent threads to use for installing
dependencies.
It defaults to the option \code{"Ncpus"} or \code{1} if unset.}
}
\description{
Uses \code{R CMD INSTALL} to install the package. Will also try to install
Expand Down
7 changes: 6 additions & 1 deletion man/install_deps.Rd
Expand Up @@ -3,7 +3,8 @@
\alias{install_deps}
\title{Install package dependencies}
\usage{
install_deps(pkg = ".", dependencies = NA)
install_deps(pkg = ".", dependencies = NA, threads = getOption("Ncpus",
1))
}
\arguments{
\item{pkg}{package description, can be path or package name. See
Expand All @@ -12,6 +13,10 @@ install_deps(pkg = ".", dependencies = NA)
\item{dependencies}{\code{logical} indicating to also install uninstalled
packages which this \code{pkg} depends on/links to/suggests. See
argument \code{dependencies} of \code{\link{install.packages}}.}

\item{threads}{number of concurrent threads to use for installing
dependencies.
It defaults to the option \code{"Ncpus"} or \code{1} if unset.}
}
\description{
Install package dependencies
Expand Down

0 comments on commit df94ccc

Please sign in to comment.