Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Suggested package after package installation #1184

Merged
merged 2 commits into from
May 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions R/deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,21 @@ dev_package_deps <- function(pkg = ".", dependencies = NA,
repos[missing_repos] <- bioc_repos[missing_repos]
}

filter_duplicate_deps(
res <- filter_duplicate_deps(
package_deps(deps, repos = repos, type = type),
remote_deps(pkg))

# We set this cache in install() so we can run install_deps() twice without
# having to re-query the remotes
installing$remote_deps %||% remote_deps(pkg))

# Only keep dependencies we actually want to use
res[res$package %in% deps, ]
}

filter_duplicate_deps <- function(cran_deps, remote_deps) {
filter_duplicate_deps <- function(cran_deps, remote_deps, dependencies) {
deps <- rbind(cran_deps, remote_deps)

# Only keep the remotes that are specified in the cran_deps
# Keep only the Non-CRAN remotes if there are duplicates as we want to install
# the development version rather than the CRAN version. The remotes will
# always be specified after the CRAN dependencies, so using fromLast will
Expand Down
20 changes: 17 additions & 3 deletions R/install.r
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,20 @@ install <-

# If building vignettes, make sure we have all suggested packages too.
if (build_vignettes && missing(dependencies)) {
dependencies <- TRUE
dependencies <- standardise_dep(TRUE)
} else {
dependencies <- standardise_dep(dependencies)
}
install_deps(pkg, dependencies = dependencies, upgrade = upgrade_dependencies,

initial_deps <- dependencies[dependencies != "Suggests"]
final_deps <- dependencies[dependencies == "Suggests"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "Enhances"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Enhances should be fine to installed in the initial installation. Note Enhances: are not installed unless explicitly set by default (see ?install.packages).

logical indicating whether to also install uninstalled
packages which these packages depend on/link
to/import/suggest (and so on recursively). Not used if
‘repos = NULL’. Can also be a character vector, a subset of
‘c("Depends", "Imports", "LinkingTo", "Suggests",
"Enhances")’

Only supported if ‘lib’ is of length one (or missing), so it is
unambiguous where to install the dependent packages. If this is not the case
it is ignored, with a warning.

The default, ‘NA’, means ‘c("Depends", "Imports",
"LinkingTo")’.

‘TRUE’ means to use ‘c("Depends", "Imports", "LinkingTo",
"Suggests")’ for ‘pkgs’ and ‘c("Depends", "Imports",
"LinkingTo")’ for added dependencies: this installs all the
packages needed to run ‘pkgs’, their examples, tests and
vignettes (if the package author specified them correctly).

In all of these, ‘"LinkingTo"’ is omitted for binary
packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there's a dependency chain like A -> (enhances) B -> (imports) A and I try to install(A) or install_deps(A)?


# cache the Remote: dependencies here so we don't have to query them each
# time we call install_deps
installing$remote_deps <- remote_deps(pkg)
on.exit(installing$remote_deps <- NULL, add = TRUE)

install_deps(pkg, dependencies = initial_deps, upgrade = upgrade_dependencies,
threads = threads, force_deps = force_deps, quiet = quiet, ...)

# Build the package. Only build locally if it doesn't have vignettes
Expand All @@ -107,7 +118,7 @@ install <-
built_path <- pkg$path
} else {
built_path <- build(pkg, tempdir(), vignettes = build_vignettes, quiet = quiet)
on.exit(unlink(built_path))
on.exit(unlink(built_path), add = TRUE)
}

opts <- c(
Expand All @@ -124,6 +135,9 @@ install <-
R(paste("CMD INSTALL ", shQuote(built_path), " ", opts, sep = ""),
quiet = quiet)

install_deps(pkg, dependencies = final_deps, upgrade = upgrade_dependencies,
threads = threads, force_deps = force_deps, quiet = quiet, ...)

if (length(metadata) > 0) {
add_metadata(inst(pkg$package), metadata)
}
Expand Down