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)#
-
- path_conversion: collections.abc.Callable[[str | collections.abc.Iterable[str] | None], str | tuple[str, Ellipsis] | None]#
- hook_source_path: pathlib.Path | None#
- 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)#
- _finalize(commands, ext)#
- activate()#
- deactivate()#
- reactivate()#
- 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.
- _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)#
- _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)#
- backslash_to_forwardslash(paths: str | collections.abc.Iterable[str] | None) str | tuple[str, Ellipsis] | 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)#
- 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)#
- 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#
- 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#
- 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#
- class PowerShellActivator(arguments=None)#
Bases:
_Activator
- pathsep_join#
- sep#
- path_conversion#
- script_extension = '.ps1'#
- tempfile_extension#
- command_join = '\n'#
- unset_var_tmpl = '$Env:%s = $null'#
- export_var_tmpl = '$Env:%s = "%s"'#
- set_var_tmpl = '$Env:%s = "%s"'#
- run_script_tmpl = '. "%s"'#
- hook_source_path#
- 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.