activate
Conda activate and deactivate logic.
Implementation for all shell interface logic exposed via conda shell.* [activate|deactivate|reactivate|hook|commands]. This includes a custom argument parser, an abstract shell class, and special path handling for Windows.
See conda.cli.main.main_sourced for the entry point into this module.
Classes
Returns the necessary values for activation as JSON, so that tools can use them. |
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
Dynamically construct the activator class. |
Attributes
- class _Activator(arguments=None)
- pathsep_join: str
- sep: str
- path_conversion: collections.abc.Callable[[str | Iterable[str] | None], str | tuple[str, ...] | None]
- script_extension: str
- tempfile_extension: str | None
- command_join: str
- unset_var_tmpl: str
- export_var_tmpl: str
- set_var_tmpl: str
- run_script_tmpl: str
- hook_source_path: str
- get_export_unset_vars(export_metavars=True, **kwargs)
- Parameters
export_metavars -- whether to export conda_exe_vars meta variables.
kwargs -- environment variables to export. .. if you pass and set any other variable to None, then it emits it to the dict with a value of None.
- Returns
A dict of env vars to export ordered the same way as kwargs. And a list of env vars to unset.
- add_export_unset_vars(export_vars, unset_vars, **kwargs)
- get_scripts_export_unset_vars(**kwargs)
- _finalize(commands, ext)
- activate()
- deactivate()
- reactivate()
- hook(auto_activate_base=None)
- execute()
- commands()
Returns a list of possible subcommands that are valid immediately following conda at the command line. This method is generally only used by tab-completion.
- abstract _hook_preamble() str | None
- _hook_postamble() str | None
- _parse_and_set_args(arguments)
- _yield_commands(cmds_dict)
- build_activate(env_name_or_prefix)
- build_stack(env_name_or_prefix)
- _build_activate_stack(env_name_or_prefix, stack)
- build_deactivate()
- build_reactivate()
- _get_starting_path_list()
- _get_path_dirs(prefix, extra_library_bin=False)
- _add_prefix_to_path(prefix, starting_path_dirs=None)
- _remove_prefix_from_path(prefix, starting_path_dirs=None)
- _replace_prefix_in_path(old_prefix, new_prefix, starting_path_dirs=None)
- _update_prompt(set_vars, conda_prompt_modifier)
- _default_env(prefix)
- _prompt_modifier(prefix, conda_default_env)
- _get_activate_scripts(prefix)
- _get_deactivate_scripts(prefix)
- _get_environment_env_vars(prefix)
- expand(path)
- ensure_binary(value)
- ensure_fs_path_encoding(value)
- native_path_to_unix(paths: str | Iterable[str] | None) str | tuple[str, ...] | None
- path_identity(paths: str | Iterable[str] | None) str | tuple[str, ...] | None
- backslash_to_forwardslash(paths: str | Iterable[str] | None) str | tuple[str, ...] | None
- class PosixActivator(arguments=None)
Bases:
_Activator
- pathsep_join
- sep = '/'
- path_conversion
- script_extension = '.sh'
- tempfile_extension
- command_join = '\n'
- unset_var_tmpl = 'unset %s'
- export_var_tmpl = "export %s='%s'"
- set_var_tmpl = "%s='%s'"
- run_script_tmpl = '. "%s"'
- hook_source_path
- _update_prompt(set_vars, conda_prompt_modifier)
- _hook_preamble() str
- class CshActivator(arguments=None)
Bases:
_Activator
- pathsep_join
- sep = '/'
- path_conversion
- script_extension = '.csh'
- tempfile_extension
- command_join = ';\n'
- unset_var_tmpl = 'unsetenv %s'
- export_var_tmpl = 'setenv %s "%s"'
- set_var_tmpl = "set %s='%s'"
- run_script_tmpl = 'source "%s"'
- hook_source_path
- _update_prompt(set_vars, conda_prompt_modifier)
- _hook_preamble() str
- class XonshActivator(arguments=None)
Bases:
_Activator
- pathsep_join
- sep = '/'
- path_conversion
- script_extension
- tempfile_extension
- command_join = '\n'
- unset_var_tmpl = 'del $%s'
- export_var_tmpl = "$%s = '%s'"
- set_var_tmpl = "$%s = '%s'"
- run_script_tmpl
- hook_source_path
- _hook_preamble() str
- class CmdExeActivator(arguments=None)
Bases:
_Activator
- pathsep_join
- sep = '\\'
- path_conversion
- script_extension = '.bat'
- tempfile_extension = '.bat'
- command_join = '\n'
- unset_var_tmpl = '@SET %s='
- export_var_tmpl = '@SET "%s=%s"'
- set_var_tmpl = '@SET "%s=%s"'
- run_script_tmpl = '@CALL "%s"'
- hook_source_path
- _hook_preamble() None
- class FishActivator(arguments=None)
Bases:
_Activator
- pathsep_join
- sep = '/'
- path_conversion
- script_extension = '.fish'
- tempfile_extension
- command_join = ';\n'
- unset_var_tmpl = 'set -e %s'
- export_var_tmpl = 'set -gx %s "%s"'
- set_var_tmpl = 'set -g %s "%s"'
- run_script_tmpl = 'source "%s"'
- hook_source_path
- _hook_preamble() str
- class PowerShellActivator(arguments=None)
Bases:
_Activator
- pathsep_join
- sep
- path_conversion
- script_extension = '.ps1'
- tempfile_extension
- command_join = '\n'
- unset_var_tmpl = '$Env:%s = ""'
- export_var_tmpl = '$Env:%s = "%s"'
- set_var_tmpl = '$Env:%s = "%s"'
- run_script_tmpl = '. "%s"'
- hook_source_path
- _hook_preamble() str
- _hook_postamble() str
- class JSONFormatMixin(arguments=None)
Bases:
_Activator
Returns the necessary values for activation as JSON, so that tools can use them.
- pathsep_join
- tempfile_extension
- command_join
- _hook_preamble()
- get_scripts_export_unset_vars(**kwargs)
- _finalize(commands, ext)
- _yield_commands(cmds_dict)
- activator_map: dict[str, type[_Activator]]
- formatter_map
- _build_activator_cls(shell)
Dynamically construct the activator class.
Detect the base activator and any number of formatters (appended using '+' to the base name). For example, posix+json (as in conda shell.posix+json activate) would use the PosixActivator base class and add the JSONFormatMixin.