Skip to content

Commit

Permalink
Avoid messing up user's WORKON_HOME in examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Dec 10, 2019
1 parent c03d29d commit 5dbad88
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
14 changes: 14 additions & 0 deletions R/basiliskStart.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
#' \code{\link{getBasiliskFork}} and \code{\link{getBasiliskShared}}, to control various global options.
#'
#' @examples
#' ##################################################
#' # Creating virtualenvs in a temporary directory to
#' # avoid polluting the user's WORKON_HOME.
#' tmploc <- file.path(tempdir(), "basilisk")
#' dir.create(tmploc)
#' old <- Sys.getenv("WORKON_HOME")
#' Sys.setenv(WORKON_HOME=tmploc)
#' ##################################################
#'
#' # Loading one virtual environment into our R session:
#' setupVirtualEnv('my_package_A', c('pandas==0.25.3',
#' "python-dateutil==2.8.1", "pytz==2019.3"))
Expand Down Expand Up @@ -110,6 +119,11 @@
#' # Close persistent processes to avoid errors during CHECK.
#' basiliskStop(cl, persist=FALSE)
#' }
#'
#' ##################################################
#' # Restoring the old WORKON_HOME.
#' Sys.setenv(WORKON_HOME=old)
#' ##################################################
#' @export
#' @importFrom parallel makePSOCKcluster clusterCall makeForkCluster
#' @importFrom reticulate py_config py_available
Expand Down
15 changes: 14 additions & 1 deletion R/setupVirtualEnv.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
#' In such cases, the compatible versions of the core packages must again be explicitly listed in \code{packages}.
#'
#' @examples
#' ##################################################
#' # Creating virtualenvs in a temporary directory to
#' # avoid polluting the user's WORKON_HOME.
#' tmploc <- file.path(tempdir(), "basilisk")
#' dir.create(tmploc)
#' old <- Sys.getenv("WORKON_HOME")
#' Sys.setenv(WORKON_HOME=tmploc)
#' ##################################################
#'
#' setupVirtualEnv('my_package_A', c('pandas==0.25.3',
#' "python-dateutil==2.8.1", "pytz==2019.3"))
#' useVirtualEnv("my_package_A")
Expand All @@ -51,7 +60,11 @@
#' # No need to list versions of core packages,
#' # or to list them at all if they are dependencies.
#' setupVirtualEnv('my_package_A_alt', 'pandas')
#'
#'
#' ##################################################
#' # Restoring the old WORKON_HOME.
#' Sys.setenv(WORKON_HOME=old)
#' ##################################################
#' @seealso
#' \code{\link{listCorePackages}}, for a list of core Python packages with pinned versions.
#'
Expand Down
13 changes: 13 additions & 0 deletions R/useVirtualEnv.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,22 @@
#' @author Aaron Lun
#'
#' @examples
#' ##################################################
#' # Creating virtualenvs in a temporary directory to
#' # avoid polluting the user's WORKON_HOME.
#' tmploc <- file.path(tempdir(), "basilisk")
#' dir.create(tmploc)
#' old <- Sys.getenv("WORKON_HOME")
#' Sys.setenv(WORKON_HOME=tmploc)
#' ##################################################
#'
#' setupVirtualEnv('my_package_A_alt', 'pandas')
#' useVirtualEnv("my_package_A_alt")
#'
#' ##################################################
#' # Restoring the old WORKON_HOME.
#' Sys.setenv(WORKON_HOME=old)
#' ##################################################
#' @seealso
#' \code{\link{basiliskStart}}, for how these virtual environments should be used.
#'
Expand Down
14 changes: 14 additions & 0 deletions man/basiliskStart.Rd

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

13 changes: 13 additions & 0 deletions man/setupVirtualEnv.Rd

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

13 changes: 13 additions & 0 deletions man/useVirtualEnv.Rd

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

0 comments on commit 5dbad88

Please sign in to comment.