context#

Conda 的全局配置对象。

context 将所有配置文件、环境变量和命令行参数聚合到一个全局有状态对象中,供 conda 的所有部分使用。

#

Context

ContextStackObject

ContextStack

PluginConfig

用于保存 conda 插件设置的类。

函数#

user_data_dir([appname, appauthor, version, roaming])

mockable_context_envs_dirs(root_writable, root_prefix, ...)

channel_alias_validation(value)

default_python_default()

default_python_validation(value)

ssl_verify_validation(value)

_warn_defaults_deprecation()

reset_context([search_path, argparse_args])

fresh_context([env, search_path, argparse_args])

stack_context(pushing[, search_path, argparse_args])

stack_context_default(pushing[, argparse_args])

replace_context([pushing, search_path, argparse_args])

replace_context_default([pushing, argparse_args])

env_name(prefix)

locate_prefix_by_name(name[, envs_dirs])

根据 conda 环境名称查找前缀的位置。如果位置不存在,则

validate_channels(→ tuple[str, Ellipsis])

验证给定的频道 URL 是否基于 context 的允许列表

validate_prefix_name(→ str)

运行各种验证以确保 prefix_name 有效

determine_target_prefix(ctx[, args])

获取要操作的前缀。前缀可能尚不存在。

_first_writable_envs_dir()

get_plugin_config_data(→ dict[pathlib.Path, dict[str, ...)

这用于将提供的字典中“plugins”键下的所有内容移动

add_plugin_setting(name, parameter[, aliases])

将设置添加到 PluginConfig

remove_all_plugin_settings(→ None)

PluginConfig 类中删除所有附加的设置

属性#

_platform_map#
non_x86_machines#
_arch_names#
user_rc_path#
sys_rc_path#
user_data_dir(appname: str | None = None, appauthor: str | None | Literal[False] = None, version: str | None = None, roaming: bool = False)#
mockable_context_envs_dirs(root_writable, root_prefix, _envs_dirs)#
channel_alias_validation(value)#
default_python_default()#
default_python_validation(value)#
ssl_verify_validation(value)#
_warn_defaults_deprecation()#
class Context(search_path=None, argparse_args=None, **kwargs)#

基类:conda.common.configuration.Configuration

property plugin_manager: conda.plugins.manager.CondaPluginManager#

这是访问此应用程序的 PluginManager 对象的首选方法,并且位于此处以避免代码其他地方的循环导入问题。

property conda_build_local_paths#
property conda_build_local_urls#
property croot#

这是源缓存和工作文件夹的存放位置

property local_build_root#
property conda_build#
property arch_name#
property platform#
property default_threads: int | None#
property repodata_threads: int | None#
property fetch_threads: int | None#

如果两者都未被覆盖 (0),则返回实验确定的值 5

property verify_threads: int | None#
property execute_threads#
property subdir#
property subdirs#
property bits#
property root_writable#
property envs_dirs#
property pkgs_dirs#
property default_prefix#
property active_prefix#
property shlvl#
property aggressive_update_packages#
property target_prefix#
property conda_prefix#
property conda_exe#
property av_data_dir#

可以在这里找到关键工件验证数据(例如,各种公钥)。

property signing_metadata_url_base#

工件验证签名元数据的基本 URL (*.root.json, key_mgr.json)。

property conda_exe_vars_dict#

如果需要,vars 可以相互引用,因为 dict 是有序的。 None 表示取消设置。

property migrated_channel_aliases#
property prefix_specified#
property channels#
property config_files#
property use_only_tar_bz2#
property binstar_upload#
property trace: bool#

context.verbosity >=4 的别名。

property debug: bool#

context.verbosity >=3 的别名。

property info: bool#

context.verbosity >=2 的别名。

property verbose: bool#

context.verbosity >=1 的别名。

property verbosity: int#

详细级别。

为了代码更简洁易读,最好使用以下别名属性

context.trace context.debug context.info context.verbose context.log_level

property log_level: int#

将 context.verbosity 映射到日志级别。

property console: str#
property category_map#
add_pip_as_python_dependency#
allow_conda_downgrades#
allow_cycles#
auto_update_conda#
auto_activate_base#
auto_stack#
notify_outdated_conda#
clobber#
changeps1#
env_prompt#
create_default_packages#
register_envs#
default_python#
download_only#
enable_private_envs#
force_32bit#
non_admin_enabled#
pip_interop_enabled#
_default_threads#
_repodata_threads#
_fetch_threads#
_verify_threads#
_execute_threads#
_aggressive_update_packages#
safety_checks#
extra_safety_checks#
_signing_metadata_url_base#
path_conflict#
pinned_packages#
disallowed_packages#
rollback_enabled#
track_features#
use_index_cache#
separate_format_cache#
_root_prefix#
_envs_dirs#
_pkgs_dirs#
_subdir#
_subdirs#
local_repodata_ttl#
ssl_verify#
client_ssl_cert#
client_ssl_cert_key#
proxy_servers#
remote_connect_timeout_secs#
remote_read_timeout_secs#
remote_max_retries#
remote_backoff_factor#
add_anaconda_token#
allow_non_channel_urls#
_channel_alias#
channel_priority#
_channels#
channel_settings#
_custom_channels#
_custom_multichannels#
_default_channels#
_migrated_channel_aliases#
migrated_custom_channels#
override_channels_enabled#
show_channel_urls#
use_local#
allowlist_channels#
denylist_channels#
restore_free_channel#
repodata_fns#
_use_only_tar_bz2#
always_copy#
always_yes#
_debug#
_trace#
dev#
dry_run#
error_upload_url#
force#
json#
_console#
offline#
quiet#
ignore_pinned#
report_errors#
shortcuts#
number_channel_notices#
shortcuts#
shortcuts_only#
_verbosity#
experimental#
no_lock#
repodata_use_zst#
envvars_force_uppercase#
deps_modifier#
update_modifier#
sat_solver#
solver_ignore_timestamps#
solver#
force_remove#
force_reinstall#
target_prefix_override#
unsatisfiable_hints#
unsatisfiable_hints_check_depth#
bld_path#
anaconda_upload#
_croot#
_conda_build#
no_plugins#
post_build_validation()#
plugins() PluginConfig#

访问 settings 插件钩子引入的设置的首选方式

_native_subdir()#
known_subdirs()#
trash_dir()#
root_prefix()#
channel_alias()#
default_channels()#
custom_multichannels()#
custom_channels()#
solver_user_agent()#
user_agent()#
_override(key, value)#

TODO: This might be broken in some ways. Unsure what happens if the old value is a property and gets set to a new value. Or if the new value overrides the validation logic on the underlying ParameterLoader instance.

Investigate and implement in a safer way.

requests_version()#
python_implementation_name_version()#
platform_system_release()#
os_distribution_name_version()#
libc_family_version()#
get_descriptions()#
description_map()#
reset_context(search_path=SEARCH_PATH, argparse_args=None)#
fresh_context(env=None, search_path=SEARCH_PATH, argparse_args=None, **kwargs)#
class ContextStackObject(search_path=SEARCH_PATH, argparse_args=None)#
set_value(search_path=SEARCH_PATH, argparse_args=None)#
apply()#
class ContextStack#
push(search_path, argparse_args)#
apply()#
pop()#
replace(search_path, argparse_args)#
context_stack#
stack_context(pushing, search_path=SEARCH_PATH, argparse_args=None)#
stack_context_default(pushing, argparse_args=None)#
replace_context(pushing=None, search_path=SEARCH_PATH, argparse_args=None)#
replace_context_default(pushing=None, argparse_args=None)#
conda_tests_ctxt_mgmt_def_pol#
env_name(prefix)#
locate_prefix_by_name(name, envs_dirs=None)#

根据 conda 环境名称查找前缀的位置。如果该位置不存在,则会引发错误。

validate_channels(channels: collections.abc.Iterator[str]) tuple[str, Ellipsis]#

验证给定的频道 URL 是否基于上下文的允许列表和拒绝列表配置被允许。

参数:

channels -- 要验证的频道列表(URL 或名称)。

抛出异常:
validate_prefix_name(prefix_name: str, ctx: Context, allow_base=True) str#

运行各种验证以确保 prefix_name 有效

determine_target_prefix(ctx, args=None)#

获取要操作的前缀。前缀可能尚不存在。

参数:
  • ctx -- conda 的上下文

  • args -- 来自命令行的 argparse 参数

返回: 前缀 抛出异常: 如果前缀无效,则抛出 CondaEnvironmentNotFoundError 异常

_first_writable_envs_dir()#
get_plugin_config_data(data: dict[pathlib.Path, dict[str, conda.common.configuration.RawParameter]]) dict[pathlib.Path, dict[str, conda.common.configuration.RawParameter]]#

这用于将提供的字典中 “plugins” 键下的所有内容移动到返回字典的顶层。然后,返回的字典将传递给 PluginConfig。

class PluginConfig(data)#

用于保存 conda 插件设置的类。

由此类创建的对象应该仅通过 conda.base.context.Context.plugins 访问。

当这个类通过 add_plugin_setting() 函数更新时,它会添加新的设置属性,这些属性可以在之后通过 context 对象访问。

我们目前在 conda.plugins.manager.CondaPluginManager.load_settings() 中调用该函数。因为 CondaPluginManager 可以通过 settings 插件钩子访问所有已注册的插件设置。

add_plugin_setting(name: str, parameter: conda.common.configuration.Parameter, aliases: tuple[str, Ellipsis] = ())#

将设置添加到 PluginConfig

remove_all_plugin_settings() None#

PluginConfig 类中删除所有附加的设置

context#