diff --git a/R/install_rosetta.R b/R/install_rosetta.R index 8f7f6fd..94465c9 100644 --- a/R/install_rosetta.R +++ b/R/install_rosetta.R @@ -8,6 +8,7 @@ #' @param pip _logical_. Use `pip` for package installation? Default: `TRUE`. This is only relevant when Conda environments are used, as otherwise packages will be installed from the Conda repositories. #' @param system _logical_. Default: `FALSE`. If `TRUE`, try installing to system (user) site library with `system()` and set reticulate to use system Python. #' @param user _logical_. Default: `FALSE`. Pass `--user` flag. This should only be done if other installation methods fail and it is impossible to use a virtual environment. +#' @param upgrade _logical_. Install latest versions of Python packages by passing `--upgrade` flag? Default: `TRUE`. #' @param arcpy_path Argument passed to `find_python()`. Path to ArcGIS Pro Python installation e.g. ``. Set as `NULL` (default) to prevent use of ArcGIS Pro instance. #' #' @details From `reticulate::py_install()`: On Linux and OS X the "virtualenv" method will be used by default ("conda" will be used if virtualenv isn't available). On Windows, the "conda" method is always used. @@ -21,6 +22,7 @@ install_rosetta <- function(envname = NULL, conda = "auto", pip = TRUE, user = FALSE, + upgrade = TRUE, system = FALSE, arcpy_path = getOption("rosettaPTF.arcpy_path")) { @@ -39,10 +41,12 @@ install_rosetta <- function(envname = NULL, if (isFALSE(system)) { # get rosetta-soil (and numpy if needed) try(reticulate::py_install("rosetta-soil", envname = envname, method = method, - conda = conda, pip = pip, pip_options = ifelse(user, "--user", "")), silent = TRUE) + conda = conda, pip = pip, pip_options = c(ifelse(user, "--user", character()), + ifelse(upgrade, "--upgrade", character()))), silent = TRUE) } else { reticulate::use_python(p, required = TRUE) - try(system(paste(shQuote(p), "-m pip install --upgrade --user rosetta-soil")), silent = TRUE) + try(system(paste(shQuote(p), "-m pip install", ifelse(upgrade, "--upgrade", ""), + ifelse(user, "--user", ""), "rosetta-soil")), silent = TRUE) } # load modules globally in package (prevents having to reload rosettaPTF library in session) diff --git a/man/install_rosetta.Rd b/man/install_rosetta.Rd index 18bb5a5..76fe94c 100644 --- a/man/install_rosetta.Rd +++ b/man/install_rosetta.Rd @@ -10,6 +10,7 @@ install_rosetta( conda = "auto", pip = TRUE, user = FALSE, + upgrade = TRUE, system = FALSE, arcpy_path = getOption("rosettaPTF.arcpy_path") ) @@ -25,6 +26,8 @@ install_rosetta( \item{user}{\emph{logical}. Default: \code{FALSE}. Pass \code{--user} flag. This should only be done if other installation methods fail and it is impossible to use a virtual environment.} +\item{upgrade}{\emph{logical}. Install latest versions of Python packages by passing \code{--upgrade} flag? Default: \code{TRUE}.} + \item{system}{\emph{logical}. Default: \code{FALSE}. If \code{TRUE}, try installing to system (user) site library with \code{system()} and set reticulate to use system Python.} \item{arcpy_path}{Argument passed to \code{find_python()}. Path to ArcGIS Pro Python installation e.g. ``. Set as \code{NULL} (default) to prevent use of ArcGIS Pro instance.}