activate#

Conda 激活和停用逻辑。

通过 conda shell.* [activate|deactivate|reactivate|hook|commands] 公开的所有 shell 接口逻辑的实现。 这包括自定义参数解析器、抽象 shell 类和 Windows 的特殊路径处理。

有关进入此模块的入口点,请参阅 conda.cli.main.main_sourced。

#

_Activator

PosixActivator

CshActivator

XonshActivator

CmdExeActivator

FishActivator

PowerShellActivator

JSONFormatMixin

返回激活所需的 JSON 格式的值,以便工具可以使用它们。

函数#

expand(path)

ensure_binary(value)

ensure_fs_path_encoding(value)

backslash_to_forwardslash(→ str | tuple[str, ...)

_build_activator_cls(shell)

动态构建激活器类。

属性#

BUILTIN_COMMANDS#
class _Activator(arguments=None)#
pathsep_join: str#
sep: str#
path_conversion: collections.abc.Callable[[str | collections.abc.Iterable[str] | None], str | tuple[str, Ellipsis] | 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: pathlib.Path | None#
get_export_unset_vars(export_metavars=True, **kwargs)#
参数:
  • export_metavars -- 是否导出 conda_exe_vars 元变量。

  • kwargs -- 要导出的环境变量。 .. 如果您传递并将任何其他变量设置为 None,则它会将其与 None 值一起发出到字典中。

返回:

要导出的环境变量字典,其顺序与 kwargs 相同。 以及要取消设置的环境变量列表。

add_export_unset_vars(export_vars, unset_vars, **kwargs)#
get_scripts_export_unset_vars(**kwargs) tuple[str, str]#
_finalize(commands, ext)#
activate()#
deactivate()#
reactivate()#
hook(auto_activate_base: bool | None = None) str#
execute()#
commands()#

返回紧跟命令行 conda 之后有效的可能子命令列表。 此方法通常仅由制表符补全使用。

abstract _hook_preamble() str | None#
_hook_postamble() str | None#
_parse_and_set_args() None#
_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)#

基类: _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)#

基类: _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)#

基类: _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)#

基类: _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)#

基类: _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)#

基类: _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#
_hook_preamble() str#
_hook_postamble() str#
class JSONFormatMixin(arguments=None)#

基类: _Activator

返回激活所需的 JSON 格式的值,以便工具可以使用它们。

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)#

动态构建激活器类。

检测基础激活器和任意数量的格式化器(使用“+”附加到基本名称)。例如,posix+json(如 conda shell.posix+json activate 中所示)将使用 PosixActivator 基类并添加 JSONFormatMixin