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

Context

ContextStackObject

ContextStack

Functions

mockable_context_envs_dirs(root_writable, root_prefix, ...)

channel_alias_validation(value)

default_python_default()

default_python_validation(value)

ssl_verify_validation(value)

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

_get_cpu_info()

env_name(prefix)

locate_prefix_by_name(name[, envs_dirs])

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

validate_prefix_name(→ str)

Run various validations to make sure prefix_name is valid

determine_target_prefix(ctx[, args])

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

_first_writable_envs_dir()

Attributes

_platform_map

non_x86_machines

_arch_names

user_rc_path

sys_rc_path

context_stack

conda_tests_ctxt_mgmt_def_pol

context

_platform_map
non_x86_machines
_arch_names
user_rc_path
sys_rc_path
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)
class Context(search_path=None, argparse_args=None, **kwargs)

Bases: conda.common.configuration.Configuration

property plugin_manager

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
property conda_build_local_urls
property croot

This is where source caches and work folders live

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
property verify_threads: int | None
property execute_threads
property subdir
property subdirs
property bits
property root_dir: os.PathLike
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

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

property signing_metadata_url_base

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

property conda_exe_vars_dict

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

property migrated_channel_aliases
property prefix_specified
property channels
property config_files
property use_only_tar_bz2
property binstar_upload
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 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
restore_free_channel
repodata_fns
_use_only_tar_bz2
always_copy
always_yes
_debug
_trace
dev
dry_run
error_upload_url
force
json
offline
quiet
ignore_pinned
report_errors
shortcuts
number_channel_notices
_verbosity
experimental
no_lock
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()
known_subdirs()
trash_dir()
root_prefix()
channel_alias()
default_channels()
custom_multichannels()
custom_channels()
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()
cpu_flags()
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
_get_cpu_info()
env_name(prefix)
locate_prefix_by_name(name, envs_dirs=None)

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

validate_prefix_name(prefix_name: str, ctx: Context, allow_base=True) str

Run various validations to make sure prefix_name is valid

determine_target_prefix(ctx, args=None)

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()
context