conda.api

class Solver(prefix, channels, subdirs=(), specs_to_add=(), specs_to_remove=())

Beta While in beta, expect both major and minor changes across minor releases.

A high-level API to conda's solving logic. Three public methods are provided to access a solution in various forms.

solve_final_state(update_modifier=<conda.auxlib._Null object>, deps_modifier=<conda.auxlib._Null object>, prune=<conda.auxlib._Null object>, ignore_pinned=<conda.auxlib._Null object>, force_remove=<conda.auxlib._Null object>)

Beta While in beta, expect both major and minor changes across minor releases.

Gives the final, solved state of the environment.

Parameters
  • deps_modifier (DepsModifier) -- An optional flag indicating special solver handling for dependencies. The default solver behavior is to be as conservative as possible with dependency updates (in the case the dependency already exists in the environment), while still ensuring all dependencies are satisfied. Options include * NO_DEPS * ONLY_DEPS * UPDATE_DEPS * UPDATE_DEPS_ONLY_DEPS * FREEZE_INSTALLED

  • prune (bool) -- If True, the solution will not contain packages that were previously brought into the environment as dependencies but are no longer required as dependencies and are not user-requested.

  • ignore_pinned (bool) -- If True, the solution will ignore pinned package configuration for the prefix.

  • force_remove (bool) -- Forces removal of a package without removing packages that depend on it.

Returns

In sorted dependency order from roots to leaves, the package references for the solved state of the environment.

Return type

Tuple[PackageRef]

solve_for_diff(update_modifier=<conda.auxlib._Null object>, deps_modifier=<conda.auxlib._Null object>, prune=<conda.auxlib._Null object>, ignore_pinned=<conda.auxlib._Null object>, force_remove=<conda.auxlib._Null object>, force_reinstall=False)

Beta While in beta, expect both major and minor changes across minor releases.

Gives the package references to remove from an environment, followed by the package references to add to an environment.

Parameters
Returns

A two-tuple of PackageRef sequences. The first is the group of packages to remove from the environment, in sorted dependency order from leaves to roots. The second is the group of packages to add to the environment, in sorted dependency order from roots to leaves.

Return type

Tuple[PackageRef], Tuple[PackageRef]

solve_for_transaction(update_modifier=<conda.auxlib._Null object>, deps_modifier=<conda.auxlib._Null object>, prune=<conda.auxlib._Null object>, ignore_pinned=<conda.auxlib._Null object>, force_remove=<conda.auxlib._Null object>, force_reinstall=False)

Beta While in beta, expect both major and minor changes across minor releases.

Gives an UnlinkLinkTransaction instance that can be used to execute the solution on an environment.

Parameters
Returns

Return type

UnlinkLinkTransaction

class SubdirData(channel)

Beta While in beta, expect both major and minor changes across minor releases.

High-level management and usage of repodata.json for subdirs.

iter_records()

Beta While in beta, expect both major and minor changes across minor releases.

Returns

A generator over all records contained in the repodata.json

instance. Warning: this is a generator that is exhausted on first use.

Return type

Iterable[PackageRecord]

query(package_ref_or_match_spec)

Beta While in beta, expect both major and minor changes across minor releases.

Run a query against this specific instance of repodata.

Parameters

package_ref_or_match_spec (PackageRef or MatchSpec or str) -- Either an exact PackageRef to match against, or a MatchSpec query object. A str will be turned into a MatchSpec automatically.

Returns

Tuple[PackageRecord]

static query_all(package_ref_or_match_spec, channels=None, subdirs=None)

Beta While in beta, expect both major and minor changes across minor releases.

Run a query against all repodata instances in channel/subdir matrix.

Parameters
  • package_ref_or_match_spec (PackageRef or MatchSpec or str) -- Either an exact PackageRef to match against, or a MatchSpec query object. A str will be turned into a MatchSpec automatically.

  • channels (Iterable[Channel or str] or None) -- An iterable of urls for channels or Channel objects. If None, will fall back to context.channels.

  • subdirs (Iterable[str] or None) -- If None, will fall back to context.subdirs.

Returns

Tuple[PackageRecord]

reload()

Beta While in beta, expect both major and minor changes across minor releases.

Update the instance with new information. Backing information (i.e. repodata.json) is lazily downloaded/loaded on first use by the other methods of this class. You should only use this method if you are sure you have outdated data.

Returns

SubdirData

class PackageCacheData(pkgs_dir)

Beta While in beta, expect both major and minor changes across minor releases.

High-level management and usage of package caches.

static first_writable(pkgs_dirs=None)

Beta While in beta, expect both major and minor changes across minor releases.

Get an instance object for the first writable package cache.

Parameters

pkgs_dirs (Iterable[str]) -- If None, will fall back to context.pkgs_dirs.

Returns

An instance for the first writable package cache.

Return type

PackageCacheData

get(package_ref, default=<conda.auxlib._Null object>)

Beta While in beta, expect both major and minor changes across minor releases.

Parameters
  • package_ref (PackageRef) -- A PackageRef instance representing the key for the PackageCacheRecord being sought.

  • default -- The default value to return if the record does not exist. If not specified and no record exists, KeyError is raised.

Returns

PackageCacheRecord

property is_writable

Beta While in beta, expect both major and minor changes across minor releases.

Indicates if the package cache location is writable or read-only.

Returns

bool

iter_records()

Beta While in beta, expect both major and minor changes across minor releases.

Returns

A generator over all records contained in the package

cache instance. Warning: this is a generator that is exhausted on first use.

Return type

Iterable[PackageCacheRecord]

query(package_ref_or_match_spec)

Beta While in beta, expect both major and minor changes across minor releases.

Run a query against this specific package cache instance.

Parameters

package_ref_or_match_spec (PackageRef or MatchSpec or str) -- Either an exact PackageRef to match against, or a MatchSpec query object. A str will be turned into a MatchSpec automatically.

Returns

Tuple[PackageCacheRecord]

static query_all(package_ref_or_match_spec, pkgs_dirs=None)

Beta While in beta, expect both major and minor changes across minor releases.

Run a query against all package caches.

Parameters
  • package_ref_or_match_spec (PackageRef or MatchSpec or str) -- Either an exact PackageRef to match against, or a MatchSpec query object. A str will be turned into a MatchSpec automatically.

  • pkgs_dirs (Iterable[str] or None) -- If None, will fall back to context.pkgs_dirs.

Returns

Tuple[PackageCacheRecord]

reload()

Beta While in beta, expect both major and minor changes across minor releases.

Update the instance with new information. Backing information (i.e. contents of the pkgs_dir) is lazily loaded on first use by the other methods of this class. You should only use this method if you are sure you have outdated data.

Returns

PackageCacheData

class PrefixData(prefix_path)

Beta While in beta, expect both major and minor changes across minor releases.

High-level management and usage of conda environment prefixes.

get(package_ref, default=<conda.auxlib._Null object>)

Beta While in beta, expect both major and minor changes across minor releases.

Parameters
  • package_ref (PackageRef) -- A PackageRef instance representing the key for the PrefixRecord being sought.

  • default -- The default value to return if the record does not exist. If not specified and no record exists, KeyError is raised.

Returns

PrefixRecord

property is_writable

Beta While in beta, expect both major and minor changes across minor releases.

Indicates if the prefix is writable or read-only.

Returns

True if the prefix is writable. False if read-only. None if the prefix does not exist as a conda environment.

Return type

bool or None

iter_records()

Beta While in beta, expect both major and minor changes across minor releases.

Returns

A generator over all records contained in the prefix.

Warning: this is a generator that is exhausted on first use.

Return type

Iterable[PrefixRecord]

query(package_ref_or_match_spec)

Beta While in beta, expect both major and minor changes across minor releases.

Run a query against this specific prefix instance.

Parameters

package_ref_or_match_spec (PackageRef or MatchSpec or str) -- Either an exact PackageRef to match against, or a MatchSpec query object. A str will be turned into a MatchSpec automatically.

Returns

Tuple[PrefixRecord]

reload()

Beta While in beta, expect both major and minor changes across minor releases.

Update the instance with new information. Backing information (i.e. contents of the conda-meta directory) is lazily loaded on first use by the other methods of this class. You should only use this method if you are sure you have outdated data.

Returns

PrefixData