envs_manager#
Tools for managing conda environments.
Functions#
Gets the path to the user's environments.txt file. |
|
|
Registers an environment by adding it to environments.txt file. |
|
Unregisters an environment by removing its entry from the environments.txt file if certain conditions are met. |
|
Lists all known conda environment prefixes. |
|
Queries all known prefixes for a given specification. |
|
Cleans the environments.txt file by removing specified locations. |
|
Rewrites the environments.txt file with the specified prefixes. |
- get_user_environments_txt_file(userhome: str = '~') str#
Gets the path to the user's environments.txt file.
- Parameters:
userhome -- The home directory of the user.
- Returns:
Path to the environments.txt file.
- register_env(location: str) None#
Registers an environment by adding it to environments.txt file.
- Parameters:
location -- The file path of the environment to register.
- unregister_env(location: str) None#
Unregisters an environment by removing its entry from the environments.txt file if certain conditions are met.
The environment is only unregistered if its associated 'conda-meta' directory exists and contains no significant files other than 'history'. If these conditions are met, the environment's path is removed from environments.txt.
- Parameters:
location -- The file path of the environment to unregister.
- list_all_known_prefixes() list[str]#
Lists all known conda environment prefixes.
- Returns:
A list of all known conda environment prefixes.
- query_all_prefixes(spec: str) collections.abc.Iterator[tuple[str, tuple]]#
Queries all known prefixes for a given specification.
- Parameters:
spec -- The specification to query for.
- Returns:
An iterator of tuples containing the prefix and the query results.
- _clean_environments_txt(environments_txt_file: str, remove_location: str | None = None) tuple[str, Ellipsis]#
Cleans the environments.txt file by removing specified locations.
- Parameters:
environments_txt_file -- The file path of environments.txt.
remove_location -- Optional location to remove from the file.
- Returns:
A tuple of the cleaned lines.