Skip to content

Commit

Permalink
Merge pull request #1657 from rstudio/virtualenv-root-env-var
Browse files Browse the repository at this point in the history
Support `RETICULATE_VIRTUALENV_ROOT` env var
  • Loading branch information
t-kalinowski authored Sep 4, 2024
2 parents 27d6e73 + 3db261b commit 922164f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion R/virtualenv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion man/virtualenv-tools.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 922164f

Please sign in to comment.