conda.api
¶
-
class
conda.api.
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=<auxlib._Null object>, deps_modifier=<auxlib._Null object>, prune=<auxlib._Null object>, ignore_pinned=<auxlib._Null object>, force_remove=<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]
- deps_modifier (DepsModifier) –
-
solve_for_diff
(update_modifier=<auxlib._Null object>, deps_modifier=<auxlib._Null object>, prune=<auxlib._Null object>, ignore_pinned=<auxlib._Null object>, force_remove=<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: - deps_modifier (DepsModifier) – See
solve_final_state()
. - prune (bool) – See
solve_final_state()
. - ignore_pinned (bool) – See
solve_final_state()
. - force_remove (bool) – See
solve_final_state()
. - force_reinstall (bool) – For requested specs_to_add that are already satisfied in the environment, instructs the solver to remove the package and spec from the environment, and then add it back–possibly with the exact package instance modified, depending on the spec exactness.
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]
- deps_modifier (DepsModifier) – See
-
solve_for_transaction
(update_modifier=<auxlib._Null object>, deps_modifier=<auxlib._Null object>, prune=<auxlib._Null object>, ignore_pinned=<auxlib._Null object>, force_remove=<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: - deps_modifier (DepsModifier) – See
solve_final_state()
. - prune (bool) – See
solve_final_state()
. - ignore_pinned (bool) – See
solve_final_state()
. - force_remove (bool) – See
solve_final_state()
. - force_reinstall (bool) – See
solve_for_diff()
.
Returns: Return type: UnlinkLinkTransaction
- deps_modifier (DepsModifier) – See
-
-
class
conda.api.
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 aMatchSpec
query object. Astr
will be turned into aMatchSpec
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 aMatchSpec
query object. Astr
will be turned into aMatchSpec
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]
- package_ref_or_match_spec (PackageRef or MatchSpec or str) – Either an exact
-
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
conda.api.
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=<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 thePackageCacheRecord
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
- package_ref (PackageRef) – A
-
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 aMatchSpec
query object. Astr
will be turned into aMatchSpec
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 aMatchSpec
query object. Astr
will be turned into aMatchSpec
automatically. - pkgs_dirs (Iterable[str] or None) – If None, will fall back to context.pkgs_dirs.
Returns: Tuple[PackageCacheRecord]
- package_ref_or_match_spec (PackageRef or MatchSpec or str) – Either an exact
-
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
-
static
-
class
conda.api.
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=<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 thePrefixRecord
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
- package_ref (PackageRef) – A
-
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 aMatchSpec
query object. Astr
will be turned into aMatchSpec
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
-