Skip to content

install#

install(records, target_prefix, cache_dir=None, installed_packages=None, platform=None, execute_link_scripts=False, show_progress=True, client=None) async #

Create an environment by downloading and linking the dependencies in the target_prefix directory.

Warning

When execute_link_scripts is set to True the post-link and pre-unlink scripts of packages will be executed. These scripts are not sandboxed and can be used to execute arbitrary code. It is therefor discouraged to enable executing link scripts.

Example#

>>> import asyncio
>>> from rattler import solve, install
>>> from tempfile import TemporaryDirectory
>>> temp_dir = TemporaryDirectory()
>>>
>>> async def main():
...     # Solve an environment with python 3.9 for the current platform
...     records = await solve(channels=["conda-forge"], specs=["python 3.9.*"])
...
...     # Link the environment in a temporary directory (you can pass any kind of path here).
...     await install(records, target_prefix=temp_dir.name)
...
...     # That's it! The environment is now created.
...     # You will find Python under `f"{temp_dir.name}/bin/python"` or `f"{temp_dir.name}/python.exe"` on Windows.
>>> asyncio.run(main())

Parameters:

Name Type Description Default
records List[RepoDataRecord]

A list of solved RepoDataRecords.

required
target_prefix str | PathLike[str]

Path to the directory where the environment should be created.

required
cache_dir Optional[PathLike[str]]

Path to directory where the dependencies will be downloaded and cached.

None
installed_packages Optional[List[PrefixRecord]]

A list of PrefixRecords which are already installed in the target_prefix. This can be obtained by loading PrefixRecords from {target_prefix}/conda-meta/. If None is specified then the target_prefix will be scanned for installed packages.

None
platform Optional[Platform]

Target platform to create and link the environment. Defaults to current platform.

None
execute_link_scripts bool

whether to execute the post-link and pre-unlink scripts that may be part of a package. Defaults to False.

False
show_progress bool

If set to True a progress bar will be shown on the CLI.

True
client Optional[Client]

An authenticated client to use for downloading packages. If not specified a default client will be used.

None