:py:mod:`context` ================= .. py:module:: conda.base.context .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: conda.base.context.Context conda.base.context.ContextStackObject conda.base.context.ContextStack Functions --------- .. autoapisummary:: conda.base.context.user_data_dir conda.base.context.mockable_context_envs_dirs conda.base.context.channel_alias_validation conda.base.context.default_python_default conda.base.context.default_python_validation conda.base.context.list_fields_validation conda.base.context.ssl_verify_validation conda.base.context._warn_defaults_deprecation conda.base.context.reset_context conda.base.context.fresh_context conda.base.context.stack_context conda.base.context.stack_context_default conda.base.context.replace_context conda.base.context.replace_context_default conda.base.context.env_name conda.base.context.locate_prefix_by_name conda.base.context.validate_channels conda.base.context.validate_prefix_name conda.base.context.determine_target_prefix conda.base.context._first_writable_envs_dir conda.base.context.get_plugin_config_data conda.base.context.add_plugin_setting conda.base.context.remove_all_plugin_settings Attributes ---------- .. autoapisummary:: conda.base.context._platform_map conda.base.context.non_x86_machines conda.base.context._arch_names conda.base.context.user_rc_path conda.base.context.sys_rc_path conda.base.context.context_stack conda.base.context.conda_tests_ctxt_mgmt_def_pol conda.base.context.context .. py:data:: _platform_map .. py:data:: non_x86_machines .. py:data:: _arch_names .. py:data:: user_rc_path :type: conda.common.path.PathType .. py:data:: sys_rc_path :type: conda.common.path.PathType .. py:function:: user_data_dir(appname: str | None = None, appauthor: str | None | Literal[False] = None, version: str | None = None, roaming: bool = False) -> conda.common.path.PathType .. py:function:: 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] .. py:function:: channel_alias_validation(value: str) -> str | Literal[True] .. py:function:: default_python_default() -> str .. py:function:: default_python_validation(value: str) -> str | Literal[True] .. py:function:: list_fields_validation(value: collections.abc.Iterable[str]) -> str | Literal[True] .. py:function:: ssl_verify_validation(value: str) -> str | Literal[True] .. py:function:: _warn_defaults_deprecation() -> None .. py:class:: Context(search_path: conda.common.path.PathsType | None = None, argparse_args: argparse.Namespace | None = None, **kwargs) Bases: :py:obj:`conda.common.configuration.Configuration` .. py:property:: pip_interop_enabled .. py:property:: plugin_manager :type: 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. .. py:property:: conda_build_local_paths :type: tuple[conda.common.path.PathType, Ellipsis] .. py:property:: conda_build_local_urls :type: tuple[str, Ellipsis] .. py:property:: croot :type: conda.common.path.PathType This is where source caches and work folders live .. py:property:: local_build_root :type: conda.common.path.PathType .. py:property:: conda_build :type: dict[str, Any] .. py:property:: arch_name :type: str .. py:property:: platform :type: str .. py:property:: default_threads :type: int | None .. py:property:: repodata_threads :type: int | None .. py:property:: fetch_threads :type: int | None If both are not overriden (0), return experimentally-determined value of 5 .. py:property:: verify_threads :type: int | None .. py:property:: execute_threads :type: int | None .. py:property:: subdir :type: str .. py:property:: subdirs :type: tuple[str, str] .. py:property:: bits :type: int .. py:property:: root_writable :type: bool .. py:property:: envs_dirs :type: tuple[conda.common.path.PathType, Ellipsis] .. py:property:: pkgs_dirs :type: tuple[conda.common.path.PathType, Ellipsis] .. py:property:: default_prefix :type: conda.common.path.PathType .. py:property:: active_prefix :type: conda.common.path.PathType .. py:property:: shlvl :type: int .. py:property:: aggressive_update_packages :type: tuple[conda.models.match_spec.MatchSpec, Ellipsis] .. py:property:: target_prefix :type: conda.common.path.PathType .. py:property:: conda_prefix :type: conda.common.path.PathType .. py:property:: conda_exe :type: conda.common.path.PathType .. py:property:: av_data_dir :type: conda.common.path.PathType Where critical artifact verification data (e.g., various public keys) can be found. .. py:property:: signing_metadata_url_base :type: str | None Base URL for artifact verification signing metadata (*.root.json, key_mgr.json). .. py:property:: conda_exe_vars_dict :type: dict[str, str | None] The vars can refer to each other if necessary since the dict is ordered. None means unset it. .. py:property:: migrated_channel_aliases :type: tuple[conda.models.channel.Channel, Ellipsis] .. py:property:: prefix_specified :type: bool .. py:property:: restore_free_channel :type: bool .. py:property:: channels :type: tuple[str, Ellipsis] .. py:property:: config_files :type: tuple[conda.common.path.PathType, Ellipsis] .. py:property:: use_only_tar_bz2 :type: bool .. py:property:: binstar_upload :type: bool | None .. py:property:: trace :type: bool Alias for context.verbosity >=4. .. py:property:: debug :type: bool Alias for context.verbosity >=3. .. py:property:: info :type: bool Alias for context.verbosity >=2. .. py:property:: verbose :type: bool Alias for context.verbosity >=1. .. py:property:: verbosity :type: 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 .. py:property:: log_level :type: int Map context.verbosity to logging level. .. py:property:: console :type: str .. py:property:: auto_activate_base :type: bool .. py:property:: default_activation_env :type: str .. py:property:: category_map :type: dict[str, tuple[str, Ellipsis]] .. py:attribute:: add_pip_as_python_dependency .. py:attribute:: allow_conda_downgrades .. py:attribute:: allow_cycles .. py:attribute:: allow_softlinks .. py:attribute:: auto_update_conda .. py:attribute:: auto_activate .. py:attribute:: _default_activation_env .. py:attribute:: auto_stack .. py:attribute:: notify_outdated_conda .. py:attribute:: clobber .. py:attribute:: changeps1 .. py:attribute:: env_prompt .. py:attribute:: environment_specifier .. py:attribute:: create_default_packages .. py:attribute:: register_envs .. py:attribute:: protect_frozen_envs .. py:attribute:: default_python .. py:attribute:: download_only .. py:attribute:: enable_private_envs .. py:attribute:: force_32bit .. py:attribute:: non_admin_enabled .. py:attribute:: prefix_data_interoperability .. py:attribute:: _default_threads .. py:attribute:: _repodata_threads .. py:attribute:: _fetch_threads .. py:attribute:: _verify_threads .. py:attribute:: _execute_threads .. py:attribute:: _aggressive_update_packages .. py:attribute:: safety_checks .. py:attribute:: extra_safety_checks .. py:attribute:: _signing_metadata_url_base .. py:attribute:: path_conflict .. py:attribute:: pinned_packages .. py:attribute:: disallowed_packages .. py:attribute:: rollback_enabled .. py:attribute:: track_features .. py:attribute:: use_index_cache .. py:attribute:: separate_format_cache .. py:attribute:: _root_prefix .. py:attribute:: _envs_dirs .. py:attribute:: _pkgs_dirs .. py:attribute:: _subdir .. py:attribute:: _subdirs .. py:attribute:: local_repodata_ttl .. py:attribute:: ssl_verify .. py:attribute:: client_ssl_cert .. py:attribute:: client_ssl_cert_key .. py:attribute:: proxy_servers .. py:attribute:: remote_connect_timeout_secs .. py:attribute:: remote_read_timeout_secs .. py:attribute:: remote_max_retries .. py:attribute:: remote_backoff_factor .. py:attribute:: add_anaconda_token .. py:attribute:: allow_non_channel_urls .. py:attribute:: _channel_alias .. py:attribute:: channel_priority .. py:attribute:: _channels .. py:attribute:: channel_settings .. py:attribute:: _custom_channels .. py:attribute:: _custom_multichannels .. py:attribute:: _default_channels .. py:attribute:: _migrated_channel_aliases .. py:attribute:: migrated_custom_channels .. py:attribute:: override_channels_enabled .. py:attribute:: show_channel_urls .. py:attribute:: use_local .. py:attribute:: allowlist_channels .. py:attribute:: denylist_channels .. py:attribute:: _restore_free_channel .. py:attribute:: repodata_fns .. py:attribute:: _use_only_tar_bz2 .. py:attribute:: always_softlink .. py:attribute:: always_copy .. py:attribute:: always_yes .. py:attribute:: _debug .. py:attribute:: _trace .. py:attribute:: dev .. py:attribute:: dry_run .. py:attribute:: error_upload_url .. py:attribute:: force .. py:attribute:: json .. py:attribute:: _console .. py:attribute:: list_fields .. py:attribute:: offline .. py:attribute:: quiet .. py:attribute:: ignore_pinned .. py:attribute:: report_errors .. py:attribute:: shortcuts .. py:attribute:: number_channel_notices .. py:attribute:: shortcuts .. py:attribute:: shortcuts_only .. py:attribute:: _verbosity .. py:attribute:: experimental .. py:attribute:: no_lock .. py:attribute:: repodata_use_zst .. py:attribute:: envvars_force_uppercase .. py:attribute:: deps_modifier .. py:attribute:: update_modifier .. py:attribute:: sat_solver .. py:attribute:: solver_ignore_timestamps .. py:attribute:: solver .. py:attribute:: force_remove .. py:attribute:: force_reinstall .. py:attribute:: target_prefix_override .. py:attribute:: unsatisfiable_hints .. py:attribute:: unsatisfiable_hints_check_depth .. py:attribute:: bld_path .. py:attribute:: anaconda_upload .. py:attribute:: _croot .. py:attribute:: _conda_build .. py:attribute:: no_plugins .. py:method:: post_build_validation() -> list[conda.common.configuration.ValidationError] .. py:method:: plugins() -> conda.plugins.config.PluginConfig Preferred way of accessing settings introduced by the settings plugin hook .. py:method:: _native_subdir() -> str .. py:method:: known_subdirs() -> set[str] .. py:method:: trash_dir() -> conda.common.path.PathType .. py:method:: root_prefix() -> conda.common.path.PathType .. py:method:: channel_alias() -> conda.models.channel.Channel .. py:method:: default_channels() -> list[conda.models.channel.Channel] .. py:method:: custom_multichannels() -> dict[str, tuple[conda.models.channel.Channel, Ellipsis]] .. py:method:: custom_channels() -> dict[str, conda.models.channel.Channel] .. py:method:: solver_user_agent() -> str .. py:method:: user_agent() -> str .. py:method:: _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. .. py:method:: requests_version() -> str .. py:method:: python_implementation_name_version() -> tuple[str, str] .. py:method:: platform_system_release() -> tuple[str, str] .. py:method:: os_distribution_name_version() -> tuple[str, str] .. py:method:: libc_family_version() -> tuple[str | None, str | None] .. py:method:: get_descriptions() -> dict[str, str] .. py:method:: description_map() -> dict[str, str] .. py:function:: reset_context(search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) -> Context .. py:function:: 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] .. py:class:: ContextStackObject(search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) .. py:method:: set_value(search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) -> None .. py:method:: apply() .. py:class:: ContextStack .. py:method:: push(search_path: conda.common.path.PathsType, argparse_args: argparse.Namespace | None) -> None .. py:method:: apply() .. py:method:: pop() .. py:method:: replace(search_path: conda.common.path.PathsType, argparse_args: argparse.Namespace | None) -> None .. py:data:: context_stack .. py:function:: stack_context(pushing: bool, search_path: conda.common.path.PathsType = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) -> None .. py:function:: stack_context_default(pushing: bool, argparse_args: argparse.Namespace | None = None) -> None .. py:function:: replace_context(pushing: bool | None = None, search_path: collections.abc.Iterable[str] = SEARCH_PATH, argparse_args: argparse.Namespace | None = None) -> None .. py:function:: replace_context_default(pushing: bool | None = None, argparse_args: argparse.Namespace | None = None) -> None .. py:data:: conda_tests_ctxt_mgmt_def_pol .. py:function:: env_name(prefix: conda.common.path.PathType) -> conda.common.path.PathType | str | None .. py:function:: 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. .. py:function:: 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. :param channels: A list of channels (either URLs or names) to validate. :raises ChannelNotAllowed: If any URL is not in the allowlist. :raises ChannelDenied: If any URL is in the denylist. .. py:function:: 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 .. py:function:: 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. :param ctx: the context of conda :param args: the argparse args from the command line Returns: the prefix Raises: CondaEnvironmentNotFoundError if the prefix is invalid .. py:function:: _first_writable_envs_dir() -> conda.common.path.PathType .. py:function:: get_plugin_config_data(data: dict[pathlib.Path, dict[str, conda.common.configuration.RawParameter]]) -> dict[pathlib.Path, dict[str, conda.common.configuration.RawParameter]] .. py:function:: add_plugin_setting(name: str, parameter: conda.common.configuration.Parameter, aliases: tuple[str, Ellipsis] = ()) -> None .. py:function:: remove_all_plugin_settings() -> None .. py:data:: context