Skip to content

Commit

Permalink
don't include suggests packages in dependencies and document how to w…
Browse files Browse the repository at this point in the history
…ork around this
  • Loading branch information
jjallaire committed Oct 4, 2013
1 parent c8f80c8 commit 8d27243
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 26 deletions.
44 changes: 27 additions & 17 deletions R/dependencies.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#' Detect Application Dependencies
#'
#' Recursively detect all package dependencies for an application. This function
Expand All @@ -8,19 +6,28 @@
#' packages they depend on.
#' @param appDir Directory containing application. Defaults to current working
#' directory.
#' @return Chracter vector with a list of recursive package dependencies for the
#' application.
#' @details
#' Dependencies are determined by parsing application source code and looking
#' for calls to \code{library}, \code{require}, \code{::}, and \code{:::}.
#'
#' If your application has a package dependency that is not detected you can
#' ensure that it is detected by inserting a call to \code{library} or
#' \code{require} with the appropriate package(s).
#'
#' Recursive dependencies are detected by examining the \code{Depends},
#' \code{Imports}, \code{LinkingTo}, and \code{Suggests} fields of the
#' packages immediately dependend on by the application.
#' @return Character vector with a list of recursive package dependencies for
#' the application.
#' @details Dependencies are determined by parsing application source code and
#' looking for calls to \code{library}, \code{require}, \code{::}, and
#' \code{:::}.
#'
#' Recursive dependencies are detected by examining the \code{Depends},
#' \code{Imports}, and \code{LinkingTo} fields of the packages immediately
#' dependend on by the application.
#'
#' @note Since the \code{Suggests} field is not included when determining
#' recursive dependencies of packages, it's possible that not every package
#' required to run your application will be detected.
#'
#' In this case, you can force a package to be included dependency by
#' inserting call(s) to \code{require} within your source directory. This code
#' need not actually execute, for example you could create a standalone file
#' named \code{dependencies.R} with the following code: \cr \cr
#' \code{require(xts)} \cr \code{require(colorspace)} \cr
#'
#' This will force the \code{xts} and \code{colorspace} packages to be
#' installed along with the rest of your application when it is deployed.
#' @examples
#' \dontrun{
#'
Expand All @@ -45,8 +52,11 @@ appDependencies <- function(appDir = getwd()) {

# then calculate recursive dependencies
available <- availableCRANSourcePackages()
which <- c("Depends", "Imports", "LinkingTo", "Suggests")
depsList <- tools::package_dependencies(pkgs, available, recursive=TRUE)
which <- c("Depends", "Imports", "LinkingTo")
depsList <- tools::package_dependencies(pkgs,
available,
which,
recursive=TRUE)

# flatten the list
deps <- unlist(depsList, recursive=TRUE, use.names=FALSE)
Expand Down
31 changes: 22 additions & 9 deletions man/appDependencies.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
to current working directory.}
}
\value{
Chracter vector with a list of recursive package
Character vector with a list of recursive package
dependencies for the application.
}
\description{
Expand All @@ -24,15 +24,28 @@
code and looking for calls to \code{library},
\code{require}, \code{::}, and \code{:::}.

If your application has a package dependency that is not
detected you can ensure that it is detected by inserting
a call to \code{library} or \code{require} with the
appropriate package(s).

Recursive dependencies are detected by examining the
\code{Depends}, \code{Imports}, \code{LinkingTo}, and
\code{Suggests} fields of the packages immediately
dependend on by the application.
\code{Depends}, \code{Imports}, and \code{LinkingTo}
fields of the packages immediately dependend on by the
application.
}
\note{
Since the \code{Suggests} field is not included when
determining recursive dependencies of packages, it's
possible that not every package required to run your
application will be detected.
In this case, you can force a package to be included
dependency by inserting call(s) to \code{require} within
your source directory. This code need not actually
execute, for example you could create a standalone file
named \code{dependencies.R} with the following code: \cr
\cr \code{require(xts)} \cr \code{require(colorspace)}
\cr
This will force the \code{xts} and \code{colorspace}
packages to be installed along with the rest of your
application when it is deployed.
}
\examples{
\dontrun{
Expand Down

0 comments on commit 8d27243

Please sign in to comment.