context#

Conda's global configuration object.

The context aggregates all configuration files, environment variables, and command line arguments into one global stateful object to be used across all of conda.

Classes#

Functions#

user_data_dir(→ conda.common.path.PathType)

mockable_context_envs_dirs(...)

channel_alias_validation(→ str | Literal[True])

default_python_default(→ str)

default_python_validation(→ str | Literal[True])

list_fields_validation(→ str | Literal[True])

ssl_verify_validation(→ str | Literal[True])

_warn_defaults_deprecation(→ None)

reset_context(→ Context)

fresh_context(→ collections.abc.Iterator[Context])

stack_context(→ None)

stack_context_default(→ None)

replace_context(→ None)

replace_context_default(→ None)

env_name(→ conda.common.path.PathType | str | None)

locate_prefix_by_name(→ conda.common.path.PathType)

Find the location of a prefix given a conda env name. If the location does not exist, an

validate_channels(→ tuple[str, Ellipsis])

Validate if the given channel URLs are allowed based on the context's allowlist

validate_prefix_name(→ conda.common.path.PathType)

Run various validations to make sure prefix_name is valid

determine_target_prefix(→ conda.common.path.PathType)

Get the prefix to operate in. The prefix may not yet exist.

_first_writable_envs_dir(→ conda.common.path.PathType)

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

add_plugin_setting() → None)

remove_all_plugin_settings(→ None)

Attributes#

_platform_map#
non_x86_machines#
_arch_names#
user_rc_path: conda.common.path.PathType#
sys_rc_path: conda.common.path.PathType#
user_data_dir(appname: str | None = None, appauthor: str | None | Literal[False] = None, version: str | None = None, roaming: bool = False) conda.common.path.PathType#
mockable_context_envs_dirs(root_writable: bool, root_prefix: conda.common.path.PathType, _envs_dirs: conda.common.path.PathsType) tuple[conda.common.path.PathType, Ellipsis]#
channel_alias_validation(value: str) str | Literal[True]#
default_python_default() str#
default_python_validation(value: str) str | Literal[True]#
list_fields_validation(value: collections.abc.Iterable[str]) str | Literal[True]#
ssl_verify_validation(value: str) str | Literal[True]#
_warn_defaults_deprecation() None#
class Context(search_path: conda.common.path.PathsType | None = None, argparse_args: argparse.Namespace | None = None, **kwargs)#

Bases: conda.common.configuration.Configuration

property pip_interop_enabled#
property plugin_manager: conda.plugins.manager.CondaPluginManager#

This is the preferred way of accessing the PluginManager object for this application and is located here to avoid problems with cyclical imports elsewhere in the code.

property conda_build_local_paths: tuple[conda.common.path.PathType, Ellipsis]#
property conda_build_local_urls: tuple[str, Ellipsis]#
property croot: conda.common.path.PathType#

This is where source caches and work folders live

property local_build_root: conda.common.path.PathType#
property conda_build: dict[str, Any]#
property arch_name: str#
property platform: str#
property default_threads: int | None#
property repodata_threads: int | None#
property fetch_threads: int | None#

If both are not overriden (0), return experimentally-determined value of 5

property verify_threads: int | None#
property execute_threads: int | None#
property subdir: str#
property subdirs: tuple[str, str]#
property bits: int#
property root_writable: bool#
property envs_dirs: tuple[conda.common.path.PathType, Ellipsis]#
property pkgs_dirs: tuple[conda.common.path.PathType, Ellipsis]#
property default_prefix: conda.common.path.PathType#
property active_prefix: conda.common.path.PathType#
property shlvl: int#
property aggressive_update_packages: tuple[conda.models.match_spec.MatchSpec, Ellipsis]#
property target_prefix: conda.common.path.PathType#
property conda_prefix: conda.common.path.PathType#
property conda_exe: conda.common.path.PathType#
property av_data_dir: conda.common.path.PathType#

Where critical artifact verification data (e.g., various public keys) can be found.

property signing_metadata_url_base: str | None#

Base URL for artifact verification signing metadata (*.root.json, key_mgr.json).

property conda_exe_vars_dict: dict[str, str | None]#

The vars can refer to each other if necessary since the dict is ordered. None means unset it.

property migrated_channel_aliases: tuple[conda.models.channel.Channel, Ellipsis]#
property prefix_specified: bool#
property restore_free_channel: bool#
property channels: tuple[str, Ellipsis]#
property config_files: tuple[conda.common.path.PathType, Ellipsis]#
property use_only_tar_bz2: bool#
property binstar_upload: bool | None#
property trace: bool#

Alias for context.verbosity >=4.

property debug: bool#

Alias for context.verbosity >=3.

property info: bool#

Alias for context.verbosity >=2.

property verbose: bool#

Alias for context.verbosity >=1.

property verbosity: int#

Verbosity level.

For cleaner and readable code it is preferable to use the following alias properties:

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

property log_level: int#

Map context.verbosity to logging level.

property console: str#
property auto_activate_base: bool#
property default_activation_env: str#
property category_map: dict[str, tuple[str, Ellipsis]]#
add_pip_as_python_dependency#
allow_conda_downgrades#
allow_cycles#
auto_update_conda#
auto_activate#
_default_activation_env#
auto_stack#
notify_outdated_conda#
clobber#
changeps1#
env_prompt#
create_default_packages#
register_envs#
protect_frozen_envs#
default_python#
download_only#
enable_private_envs#
force_32bit#
non_admin_enabled#
prefix_data_interoperability#
_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#
list_fields#
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() list[conda.common.configuration.ValidationError]#
plugins() conda.plugins.config.PluginConfig#

Preferred way of accessing settings introduced by the settings plugin hook

_native_subdir() str#
known_subdirs() set[str]#
trash_dir() conda.common.path.PathType#
root_prefix() conda.common.path.PathType#
channel_alias() conda.models.channel.Channel#
default_channels() list[conda.models.channel.Channel]#
custom_multichannels() dict[str, tuple[conda.models.channel.Channel, Ellipsis]]#
custom_channels() dict[str, conda.models.channel.Channel]#
solver_user_agent() str#
user_agent() str#
_override(key: str, value: Any) collections.abc.Iterator[None]#

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() str#
python_implementation_name_version() tuple[str, str]#
platform_system_release() tuple[str, str]#
os_distribution_name_version() tuple[str, str]#
libc_family_version() tuple[str | None, str | None]#
get_descriptions() dict[str, str]#
description_map() dict[str, str]#
reset_context(search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) Context#
fresh_context(env: dict[str, str] | None = None, search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None, **kwargs) collections.abc.Iterator[Context]#
class ContextStackObject(search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None)#
set_value(search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) None#
apply()#
class ContextStack#
push(search_path: conda.common.path.PathsType, argparse_args: argparse.Namespace | None) None#
apply()#
pop()#
replace(search_path: conda.common.path.PathsType, argparse_args: argparse.Namespace | None) None#
context_stack#
stack_context(pushing: bool, search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) None#
stack_context_default(pushing: bool, argparse_args: argparse.Namespace | None = None) None#
replace_context(pushing: bool | None = None, search_path: collections.abc.Iterable[str] = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) None#
replace_context_default(pushing: bool | None = None, argparse_args: argparse.Namespace | None = None) None#
conda_tests_ctxt_mgmt_def_pol#
env_name(prefix: conda.common.path.PathType) conda.common.path.PathType | str | None#
locate_prefix_by_name(name: str, envs_dirs: conda.common.path.PathsType | None = None) conda.common.path.PathType#

Find the location of a prefix given a conda env name. If the location does not exist, an error is raised.

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

Validate if the given channel URLs are allowed based on the context's allowlist and denylist configurations.

Parameters:

channels -- A list of channels (either URLs or names) to validate.

Raises:
validate_prefix_name(prefix_name: str, ctx: Context, allow_base: bool = True) conda.common.path.PathType#

Run various validations to make sure prefix_name is valid

determine_target_prefix(ctx: Context, args: argparse.Namespace | None = None) conda.common.path.PathType#

Get the prefix to operate in. The prefix may not yet exist.

Parameters:
  • ctx -- the context of conda

  • args -- the argparse args from the command line

Returns: the prefix Raises: CondaEnvironmentNotFoundError if the prefix is invalid

_first_writable_envs_dir() conda.common.path.PathType#
get_plugin_config_data(data: dict[pathlib.Path, dict[str, conda.common.configuration.RawParameter]]) dict[pathlib.Path, dict[str, conda.common.configuration.RawParameter]]#
add_plugin_setting(name: str, parameter: conda.common.configuration.Parameter, aliases: tuple[str, Ellipsis] = ()) None#
remove_all_plugin_settings() None#
context#