setupBasiliskEnv {basilisk}R Documentation

Set up a basilisk environments

Description

Set up a Python conda environment for isolated execution of Python code with appropriate versions of all Python packages.

Usage

setupBasiliskEnv(envpath, packages, pip = NULL)

Arguments

envpath

String containing the path to the environment to use.

packages

Character vector containing the names of conda packages to install into the environment. Version numbers must be included.

pip

Character vector containing the names of additional packages to install from PyPi using pip. Version numbers must be included.

Details

basilisk environments are simply Python conda environments that are created and managed by basilisk. Each basilisk environment can contain different Python packages with different versions, allowing us to avoid version conflicts within an R session when different Bioconductor packages (or even different functions within a single package) require incompatible versions of Python packages.

Developers of client packages should never need to call this function directly. For typical usage, setupBasiliskEnv is automatically called by basiliskStart to perform lazy installation. Developers should also create configure(.win) files to call configureBasiliskEnv, which will call setupBasiliskEnv during R package installation when BASILISK_USE_SYSTEM_DIR is set.

If a basilisk environment is already present at envpath, setupBasiliskEnv is a no-op. This ensures that the function only installs the packages once.

Value

A conda environment is created at envpath containing the specified packages. The function will return a logical scalar indicating whether creation was performed, which will be FALSE if the environment already exists.

Versioning

Pinned version numbers must be present for all requested conda packages in packages. This improved predictability makes debugging much easier when the R package is installed and executed on different systems. Note that this refers to conda packages, not Python packages, where the version notation for the former uses a single =; any == will be coerced to = automatically.

It is possible to use the pip argument to install additional packages from PyPi after all the conda packages are installed. All packages listed here are also expected to have pinned versions, this time using the == notation. However, some caution is required when mixing packages from conda and pip, see https://www.anaconda.com/using-pip-in-a-conda-environment for more details.

It is also good practice to explicitly list the versions of the dependencies of all desired packages. This protects against future changes in the behavior of your code if conda's dependency resolver defaults to a different version of a required package. We suggest using conda env export to identify relevant dependencies and include them in packages; the only reason that pinned dependencies are not mandatory is because some dependencies are OS-specific, requiring some manual pruning of the output of conda env export.

It is possible to specify a different version of Python in packages by supplying, e.g., "python=2.7.10". If no Python version is listed, the version in the base conda installation is used by default.

See Also

listCorePackages, for a list of core Python packages with pinned versions.

Examples

tmploc <- file.path(tempdir(), "my_package_A")
setupBasiliskEnv(tmploc, c('pandas=0.25.3',
    "python-dateutil=2.8.1", "pytz=2019.3"))


[Package basilisk version 1.0.2 Index]