useBasiliskEnv: Use 'basilisk' environments

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/useBasiliskEnv.R

Description

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

Usage

1
useBasiliskEnv(envpath)

Arguments

envpath

String containing the path to the basilisk environment to use.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
tmploc <- file.path(tempdir(), "my_package_B")
if (!file.exists(tmploc)) {
    setupBasiliskEnv(tmploc, c('pandas==0.25.1',
        "python-dateutil=2.8.0", "pytz=2019.3"))
}

# 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())

basilisk documentation built on Dec. 18, 2020, 2 a.m.