useBasiliskEnv: Use 'basilisk' environments

View source: R/useBasiliskEnv.R

useBasiliskEnvR Documentation

Use basilisk environments

Description

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

Usage

useBasiliskEnv(envpath, full.activation = NA)

Arguments

envpath

String containing the path to the basilisk environment to use.

full.activation

Logical scalar, see activateEnvironment for details.

Details

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

This function will modify a suite of environment variables as a side effect - see “Persistence of environment variables” in ?basiliskStart for the rationale.

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). A NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

basiliskStart, for how these basilisk environments should be used.

Examples



tmploc <- file.path(tempdir(), "my_package_A")
if (!file.exists(tmploc)) {
    setupBasiliskEnv(tmploc, c(pandas_spec()))
}

# This may or may not work, depending on whether a Python instance
# has already been loaded into this R session.
try(useBasiliskEnv(tmploc))

# This will definitely not work, as the available Python is already set.
baseloc <- basilisk.utils::getCondaDir()
status <- try(useBasiliskEnv(baseloc))

# ... except on Windows, which somehow avoids tripping the error.
stopifnot(is(status, "try-error") || basilisk.utils::isWindows())


LTLA/jormungandR documentation built on Feb. 6, 2024, 2:29 p.m.