index#
Tools for fetching the current index.
Classes#
The |
|
Index that contains a subset of available packages. |
Functions#
|
Check if the given channel URLs are allowed by the context's allowlist. |
|
Check if a distribution string matches any package in the index. |
|
Loads and populates virtual package records from conda plugins |
|
Determine the architecture specification name for the current environment. |
|
Calculate the full list of channel URLs to use based on the given parameters. |
Attributes#
- LAST_CHANNEL_URLS = []#
- check_allowlist(channel_urls: list[str]) None#
Check if the given channel URLs are allowed by the context's allowlist. :param channel_urls: A list of channel URLs to check against the allowlist. :raises ChannelNotAllowed: If any URL is not in the allowlist. :raises ChannelDenied: If any URL is in the denylist.
- class Index(channels: collections.abc.Iterable[str | conda.models.channel.Channel] = (), prepend: bool = True, platform: str | None = None, subdirs: tuple[str, Ellipsis] | None = None, use_local: bool = False, use_cache: bool | None = None, prefix: conda.common.path.PathType | conda.core.prefix_data.PrefixData | None = None, repodata_fn: str | None = context.repodata_fns[-1], use_system: bool = False)#
Bases:
collections.UserDictThe
Indexprovides information about available packages from all relevant sources.There are four types of sources for package information, namely
- Channels
represent packages available from standard sources identified with a url, mostly online, but can also be on a local filesystem using the
file://scheme. Programatically, channels are represented byconda.models.channel.Channel, their data is fetched usingconda.core.subdir_data.SubdirData.For more information see What is a "channel"?.
Individual packages from channels are usually represented by
conda.models.records.PackageRecord.- Prefix
represents packages that are already installed. Every
Indexcan be associated with exactly one Prefix, which is the location of one of the conda Environments. The package information about the installed packages is represented byconda.core.prefix_data.PrefixData.Individual packages from prefixes are usually represented by
conda.models.records.PrefixRecord.- Package Cache
represents packages that are locally unpacked, but may not be installed in the environment associated with this index. These are usually packages that have been installed in any environment of the local conda installation, but may have been removed from all environments by now.
Individual packages from the package are usually represented by
conda.models.records.PackageCacheRecord.- Virtual Packages
represent properties of the system, not actual conda packages in the normal sense. These are, for example, system packages that inform the solver about the operating system in use, or track features that can be used to steer package priority.
Individual virtual packages are represented by special
conda.models.records.PackageRecord, seeconda.models.records.PackageRecord.virtual_package()andconda.models.records.PackageRecord.feature().
Initializes a new index with the desired components.
- Parameters:
channels -- channels identified by canonical names or URLS or Channel objects; for more details, see
conda.models.channel.Channel.from_value()prepend -- if
True(default), add configured channel with higher priority than passed channels; ifFalse, do not add configured channels.platform -- see
subdirs.subdirs -- platform and subdirs determine the selection of subdirs in the channels; if both are
None, subdirs is taken from the configuration; if both are given,subdirstakes precedence andplatformis ignored; if onlyplatformis given, subdirs will be(platform, "noarch"); ifsubdirsis given, subdirs will besubdirs.use_local -- if
True, add the special "local" channel for locally built packages with lowest priority.use_cache -- if
True, add packages from the package cache.prefix -- associate prefix with this index and add its packages.
repodata_fn -- filename of the repodata, default taken from config, almost always "repodata.json".
use_system -- if
True, add system packages, that is virtual packages defined by plugins, usually used to make intrinsic information about the system, such as cpu architecture or operating system, available to the solver.
- property cache_entries: tuple[conda.models.records.PackageCacheRecord, Ellipsis]#
Contents of the package cache if active.
- Returns:
All packages available from the package cache.
- property system_packages: dict[conda.models.records.PackageRecord, conda.models.records.PackageRecord]#
System packages provided by plugins.
- Returns:
Identity mapping of the available system packages in a
dict.
- property features: dict[conda.models.records.PackageRecord, conda.models.records.PackageRecord]#
Active tracking features.
- Returns:
Identity mapping of the local tracking features in a
dict.
- property data: dict[conda.models.records.PackageRecord, conda.models.records.PackageRecord]#
The entire index as a dict; avoid if possible.
Warning
This returns the entire contents of the index as a single identity mapping in a
dict. This may be convenient, but it comes at a cost because all sources must be fully loaded at significant overhead forPackageRecordconstruction for every package.Hence, all uses of
data, including all iteration over the entire index, is strongly discouraged.
- reload(*, prefix: bool = False, cache: bool = False, features: bool = False, system: bool = False) None#
Reload one or more of the index components.
Can be used to refresh the index with new information, for example after a new package has been installed into the index.
- Parameters:
prefix -- if
True, reload the prefix data.cache -- if
True, reload the package cache.features -- if
True, reload the tracking features.system -- if
True, reload the system packages.
- get_reduced_index(specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec]) ReducedIndex#
Create a reduced index with a subset of packages.
Can be used to create a reduced index as a subset from an existing index.
- Parameters:
specs -- the specs that span the subset.
- Returns:
a reduced index with the same sources as this index, but limited to
specsand their dependency graph.
- _retrieve_from_channels(key: conda.models.records.PackageRecord) conda.models.records.PackageRecord | None#
- _retrieve_all_from_channels(key: conda.models.records.PackageRecord) list[conda.models.records.PackageRecord]#
- _update_from_prefix(key: conda.models.records.PackageRecord, prec: conda.models.records.PackageRecord | None) conda.models.records.PackageRecord | None#
- _update_from_cache(key: conda.models.records.PackageRecord, prec: conda.models.records.PackageRecord | None) conda.models.records.PackageRecord | None#
- __getitem__(key: conda.models.records.PackageRecord) conda.models.records.PackageRecord#
- __contains__(key: conda.models.records.PackageRecord) bool#
- __copy__() Self#
- class ReducedIndex(specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec], channels: tuple[str, Ellipsis] = (), prepend: bool = True, platform: str | None = None, subdirs: tuple[str, Ellipsis] | None = None, use_local: bool = False, use_cache: bool | None = None, prefix: conda.common.path.PathType | conda.core.prefix_data.PrefixData | None = None, repodata_fn: str | None = context.repodata_fns[-1], use_system: bool = False)#
Bases:
IndexIndex that contains a subset of available packages.
Like
Index, this makes information about packages from the same four sources available. However, the contents of the reduced index is limited to a subset of packages relevant to a given specification. This works by taking into account all packages that match the given specification together with their dependencies and their dependencies dependencies, etc.Note
See
Index.get_reduced_index()for convenient construction.Initialize a new reduced index.
- Parameters:
specs -- the collection of specifications that span the subset of packages.
args (all other) -- see
Index.
- dist_str_in_index(index: dict[Any, Any], dist_str: str) bool#
Check if a distribution string matches any package in the index.
- Parameters:
index -- The package index.
dist_str -- The distribution string to match against the index.
- Returns:
True if there is a match; False otherwise.
- _supplement_index_with_system(index: dict[conda.models.records.PackageRecord, conda.models.records.PackageRecord]) None#
Loads and populates virtual package records from conda plugins and adds them to the provided index, unless there is a naming conflict. :param index: The package index to supplement.
- get_archspec_name() str | None#
Determine the architecture specification name for the current environment.
- Returns:
The architecture name if available, otherwise None.
- calculate_channel_urls(channel_urls: tuple[str] = (), prepend: bool = True, platform: str | None = None, use_local: bool = False) list[str]#
Calculate the full list of channel URLs to use based on the given parameters.
- Parameters:
channel_urls -- Initial list of channel URLs.
prepend -- Whether to prepend default channels to the list.
platform -- The target platform for the channels.
use_local -- Whether to include the local channel.
- Returns:
The calculated list of channel URLs.