pkgDepTopoSort {Require} | R Documentation |
Reverse package depends
Description
This is a wrapper around tools::dependsOnPkgs
,
but with the added option of topoSort
, which
will sort them such that the packages at the top will have
the least number of dependencies that are in pkgs
.
This is essentially a topological sort, but it is done
heuristically. This can be used to e.g., detach
or
unloadNamespace
packages in order so that they each
of their dependencies are detached or unloaded first.
pkgDep2
is a convenience wrapper of pkgDep
that "goes one level in",
i.e., the first order dependencies, and runs the pkgDep
on those.
This will first look in local filesystem (in .libPaths()
) and will use a
local package to find its dependencies. If the package does not exist
locally, including whether it is the correct version, then it will look in
(currently) CRAN
and its archives (if the current CRAN
version is not the
desired version to check). It will also look on GitHub
if the package
description is of the form of a GitHub package with format
account/repo@branch
or account/repo@commit
. For this, it will attempt to
get package dependencies from the GitHub ‘DESCRIPTION’ file. This is
intended to replace tools::package_dependencies
or pkgDep
in the
miniCRAN package, but with modifications to allow multiple sources to
be searched in the same function call.
Usage
pkgDepTopoSort(
pkgs,
deps,
reverse = FALSE,
topoSort = TRUE,
libPaths,
useAllInSearch = FALSE,
returnFull = TRUE,
recursive = TRUE,
purge = getOption("Require.purge", FALSE),
which = c("Depends", "Imports", "LinkingTo"),
type = getOption("pkgType"),
verbose = getOption("Require.verbose"),
...
)
pkgDep2(...)
pkgDep(
packages,
libPaths,
which = c("Depends", "Imports", "LinkingTo"),
recursive = TRUE,
depends,
imports,
suggests,
linkingTo,
repos = getOption("repos"),
keepVersionNumber = TRUE,
includeBase = FALSE,
includeSelf = TRUE,
sort = TRUE,
simplify = TRUE,
purge = getOption("Require.purge", FALSE),
verbose = getOption("Require.verbose"),
type = getOption("pkgType"),
Additional_repositories = FALSE,
...
)
Arguments
pkgs |
A vector of package names to evaluate their reverse depends (i.e., the packages that use each of these packages) |
deps |
An optional named list of (reverse) dependencies.
If not supplied, then |
reverse |
Logical. If |
topoSort |
Logical. If |
libPaths |
A path to search for installed packages. Defaults to
|
useAllInSearch |
Logical. If |
returnFull |
Logical. Primarily useful when |
recursive |
Logical. Should dependencies of dependencies be searched,
recursively. NOTE: Dependencies of suggests will not be recursive. Default
|
purge |
Logical. Should all caches be purged? Default is
Internally, there are calls to |
which |
a character vector listing the types of dependencies, a subset
of |
type |
See |
verbose |
Numeric or logical indicating how verbose should the function
be. If -1 or -2, then as little verbosity as possible. If 0 or FALSE,
then minimal outputs; if |
... |
Currently only |
packages |
Either a character vector of packages to install via
|
depends |
Logical. Include packages listed in "Depends". Default |
imports |
Logical. Include packages listed in "Imports". Default |
suggests |
Logical. Include packages listed in "Suggests". Default
|
linkingTo |
Logical. Include packages listed in "LinkingTo". Default
|
repos |
The remote repository (e.g., a CRAN mirror), passed to either
|
keepVersionNumber |
Logical. If |
includeBase |
Logical. Should R base packages be included, specifically,
those in |
includeSelf |
Logical. If |
sort |
Logical. If |
simplify |
Logical or numeric. If |
Additional_repositories |
Logical. If |
Value
A possibly ordered, named (with packages as names) list where list elements are either full reverse depends.
Note
tools::package_dependencies
and pkgDep
will differ under the
following circumstances:
GitHub packages are not detected using
tools::package_dependencies
;-
tools::package_dependencies
does not detect the dependencies of base packages among themselves, e.g.,methods
depends onstats
andgraphics
.
Examples
## Not run:
if (Require:::.runLongExamples()) {
opts <- Require:::.setupExample()
pkgDepTopoSort(c("Require", "data.table"), reverse = TRUE)
Require:::.cleanup(opts)
}
## End(Not run)
## Not run:
if (Require:::.runLongExamples()) {
opts <- Require:::.setupExample()
pkgDep2("reproducible")
# much bigger one
pkgDep2("tidyverse")
Require:::.cleanup(opts)
}
## End(Not run)
## Not run:
if (Require:::.runLongExamples()) {
opts <- Require:::.setupExample()
pkgDep("tidyverse", recursive = TRUE)
# GitHub, local, and CRAN packages
pkgDep(c("PredictiveEcology/reproducible", "Require", "plyr"))
Require:::.cleanup(opts)
}
## End(Not run)