diff --git a/NEWS.md b/NEWS.md index 301686c57..16753cc80 100644 --- a/NEWS.md +++ b/NEWS.md @@ -35,6 +35,9 @@ - New `as.character()` method for `python.builtin.str` with support for handling embedded NULs in strings. (#1653) + +- Reticulate will now use the `RETICULATE_VIRTUALENV_ROOT` environment variable + when determining where to resolve virtual environments. (#1657) # reticulate 1.38.0 diff --git a/R/virtualenv.R b/R/virtualenv.R index f50065f2a..fca56b89c 100644 --- a/R/virtualenv.R +++ b/R/virtualenv.R @@ -5,7 +5,7 @@ #' #' Virtual environments are by default located at `~/.virtualenvs` (accessed #' with the `virtualenv_root()` function). You can change the default location -#' by defining the `WORKON_HOME` environment variable. +#' by defining the `RETICULATE_VIRTUALENV_ROOT` or `WORKON_HOME` environment variables. #' #' Virtual environments are created from another "starter" or "seed" Python #' already installed on the system. Suitable Pythons installed on the system are @@ -333,6 +333,10 @@ virtualenv_list <- function() { #' @rdname virtualenv-tools #' @export virtualenv_root <- function() { + root <- Sys.getenv("RETICULATE_VIRTUALENV_ROOT", NA_character_) + if (!is.na(root)) + return(root) + Sys.getenv("WORKON_HOME", unset = "~/.virtualenvs") } diff --git a/man/virtualenv-tools.Rd b/man/virtualenv-tools.Rd index c1fede5be..2f8eac209 100644 --- a/man/virtualenv-tools.Rd +++ b/man/virtualenv-tools.Rd @@ -128,7 +128,7 @@ R functions for managing Python \href{https://virtualenv.pypa.io/en/stable/}{vir \details{ Virtual environments are by default located at \verb{~/.virtualenvs} (accessed with the \code{virtualenv_root()} function). You can change the default location -by defining the \code{WORKON_HOME} environment variable. +by defining the \code{RETICULATE_VIRTUALENV_ROOT} or \code{WORKON_HOME} environment variables. Virtual environments are created from another "starter" or "seed" Python already installed on the system. Suitable Pythons installed on the system are