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#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Find the location of a prefix given a conda env name. If the location does not exist, an |
|
Validate if the given channel URLs are allowed based on the context's allowlist |
|
Run various validations to make sure prefix_name is valid |
|
Get the prefix to operate in. The prefix may not yet exist. |
|
|
|
|
|
|
|
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] #
- list_fields_validation(value: collections.abc.Iterable[str]) str | Literal[True] #
- 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 croot: conda.common.path.PathType#
This is where source caches and work folders live
- property local_build_root: conda.common.path.PathType#
- property fetch_threads: int | None#
If both are not overriden (0), return experimentally-determined value of 5
- property default_prefix: conda.common.path.PathType#
- property active_prefix: conda.common.path.PathType#
- 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 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
- add_pip_as_python_dependency#
- allow_conda_downgrades#
- allow_cycles#
- allow_softlinks#
- 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_softlink#
- 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
- 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] #
- _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.
- 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#
- 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:
ChannelNotAllowed -- If any URL is not in the allowlist.
ChannelDenied -- If any URL is in the denylist.
- 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 #
- context#