useBasiliskEnv {basilisk}R Documentation

Use basilisk environments

Description

Use basilisk environments for isolated execution of Python code with appropriate versions of all Python packages.

Usage

useBasiliskEnv(envpath, dry = FALSE, required = TRUE)

Arguments

envpath

String containing the path to the basilisk environment to use.

dry

Logical scalar indicating whether only the directory should be returned without loading the environment.

required

Logical scalar indicating whether an error should be raised if the requested environment cannot be found.

Details

It is unlikely that developers should ever need to call useBasiliskEnv directly. Rather, this interaction should be automatically handled by basiliskStart.

Direct use of this function with dry=FALSE will modify some environment variables for the current R session:

If dry=TRUE, no environment variables are modified. Similarly, if the loading of the environment in envpath was not successful (i.e., loaded is FALSE), no environment variables are modified and previous is an empty list. Further note that basiliskStop will restore these environment variables to their state prior to running basiliskStart.

Value

The function will attempt to load the specified basilisk environment into the R session, possibly with the modification of some environment variables (see Details).

It returns a list containing:

If dry=TRUE, only the logical scalar in loaded is returned directly.

Author(s)

Aaron Lun

See Also

basiliskStart, for how these basilisk environments should be used.

Examples

# This may return TRUE or FALSE, depending on the available Python.
tmploc <- file.path(tempdir(), "my_package_B")
setupBasiliskEnv(tmploc, c('pandas==0.25.1',
    "python-dateutil=2.8.0", "pytz=2019.3"))
useBasiliskEnv(tmploc, required=FALSE) 

# This will return FALSE, as the available Python is already set.
baseloc <- basilisk.utils::getBasiliskDir()
useBasiliskEnv(baseloc, required=FALSE)


[Package basilisk version 1.0.2 Index]