View source: R/createEnvironment.R
createEnvironment | R Documentation |
Create a new conda environment if it does not already exist in the cache/system.
createEnvironment(
pkg,
name,
version,
packages,
cache.dir = NULL,
ignore.cache = FALSE,
conda = NULL,
channels = "conda-forge",
override.channels = TRUE,
extra = "--quiet"
)
pkg |
String containing the name of the R package that owns this conda environment. |
name |
String containing the name of the environment. |
version |
String containing the version of the environment. Ignored for system installs. |
packages |
Character vector of conda packages (possibly with version specifications) to be installed in this environment. |
cache.dir |
String containing the location of the cache for lazily instantiated environments.
If |
ignore.cache |
Logical scalar indicating whether to ignore cached environments if they already exist. Ignored for system installs. |
conda |
String containing the path to the conda command or executable.
If |
channels |
Character vector of channels to use for conda environment creation. |
override.channels |
Logical scalar indicating whether to set the |
extra |
Character vector of additional arguments to pass to |
In general, createEnvironment
should be called inside any function of a downstream package that relies on the conda environment.
On its first call, it will then lazily instantiate the environment based on the specified arguments.
All subsequent calls in the same or new R sessions will use the cached environments.
The version
string is used to distinguish between different versions of the same name
environments.
This allows package developers to safely update their environments without affecting other R installations that are re-using the same cache.
Older unused versions of the environment will be automatically removed over time via dir.expiry.
Note that the version
string does not necessarily have to be the same as the version of the pkg
package.
Any version-like string is fine as long as they are compatible with package_version
.
In fact, having independent versions for the environments and their parent package is often more convenient,
as it means that the environments don't always need to be recreated when the package is updated.
To avoid lazy evaluation, administrators of an R installation can enable system installs, see configureEnvironments
for details.
String containing the path to the conda environment.
Aaron Lun
createEnvironment(
pkg="basilisk.utils.test",
name="test_env",
version="1.0.0",
packages="hdf5"
)
# Repeated calls will just get the same environment back.
createEnvironment(
pkg="basilisk.utils.test",
name="test_env",
version="1.0.0",
packages="hdf5"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.