Skip to content

solve#

SolveStrategy = Literal['highest', 'lowest', 'lowest-direct'] module-attribute #

Defines the strategy to use when multiple versions of a package are available during solving.

solve(channels, specs, gateway=Gateway(), platforms=None, locked_packages=None, pinned_packages=None, virtual_packages=None, timeout=None, channel_priority=ChannelPriority.Strict, exclude_newer=None, strategy='highest', constraints=None) async #

Resolve the dependencies and return the RepoDataRecords that should be present in the environment.

Parameters:

Name Type Description Default
channels Sequence[Channel | str]

The channels to query for the packages.

required
specs Sequence[MatchSpec | str]

A list of matchspec to solve.

required
platforms Optional[Sequence[Platform | PlatformLiteral]]

The platforms to query for the packages. If None the current platform and noarch is used.

None
gateway Gateway

The gateway to use for acquiring repodata.

Gateway()
locked_packages Optional[Sequence[RepoDataRecord]]

Records of packages that are previously selected. If the solver encounters multiple variants of a single package (identified by its name), it will sort the records and select the best possible version. However, if there exists a locked version it will prefer that variant instead. This is useful to reduce the number of packages that are updated when installing new packages. Usually you add the currently installed packages or packages from a lock-file here.

None
pinned_packages Optional[Sequence[RepoDataRecord]]

Records of packages that are previously selected and CANNOT be changed. If the solver encounters multiple variants of a single package (identified by its name), it will sort the records and select the best possible version. However, if there is a variant available in the pinned_packages field it will always select that version no matter what even if that means other packages have to be downgraded.

None
virtual_packages Optional[Sequence[GenericVirtualPackage | VirtualPackage]]

A list of virtual packages considered active.

None
channel_priority ChannelPriority

(Default = ChannelPriority.Strict) When ChannelPriority.Strict the channel that the package is first found in will be used as the only channel for that package. When ChannelPriority.Disabled it will search for every package in every channel.

Strict
timeout Optional[timedelta]

The maximum time the solver is allowed to run.

None
exclude_newer Optional[datetime]

Exclude any record that is newer than the given datetime.

None
strategy SolveStrategy

The strategy to use when multiple versions of a package are available.

  • "highest": Select the highest compatible version of all packages.
  • "lowest": Select the lowest compatible version of all packages.
  • "lowest-direct": Select the lowest compatible version for all direct dependencies but the highest compatible version of transitive dependencies.
'highest'
constraints Optional[Sequence[MatchSpec | str]]

Additional constraints that should be satisfied by the solver. Packages included in the constraints are not necessarily installed, but they must be satisfied by the solution.

None

Returns:

Type Description
List[RepoDataRecord]

Resolved list of RepoDataRecords.

solve_with_sparse_repodata(specs, sparse_repodata, locked_packages=None, pinned_packages=None, virtual_packages=None, timeout=None, channel_priority=ChannelPriority.Strict, exclude_newer=None, strategy='highest', constraints=None) async #

Resolve the dependencies and return the RepoDataRecords that should be present in the environment.

This function is similar to solve but instead of querying for repodata with a Gateway object this function allows you to manually pass in the repodata.

Parameters:

Name Type Description Default
specs Sequence[MatchSpec | str]

A list of matchspec to solve.

required
sparse_repodata Sequence[SparseRepoData]

The repodata to query for the packages.

required
locked_packages Optional[Sequence[RepoDataRecord]]

Records of packages that are previously selected. If the solver encounters multiple variants of a single package (identified by its name), it will sort the records and select the best possible version. However, if there exists a locked version it will prefer that variant instead. This is useful to reduce the number of packages that are updated when installing new packages. Usually you add the currently installed packages or packages from a lock-file here.

None
pinned_packages Optional[Sequence[RepoDataRecord]]

Records of packages that are previously selected and CANNOT be changed. If the solver encounters multiple variants of a single package (identified by its name), it will sort the records and select the best possible version. However, if there is a variant available in the pinned_packages field it will always select that version no matter what even if that means other packages have to be downgraded.

None
virtual_packages Optional[Sequence[GenericVirtualPackage | VirtualPackage]]

A list of virtual packages considered active.

None
channel_priority ChannelPriority

(Default = ChannelPriority.Strict) When ChannelPriority.Strict the channel that the package is first found in will be used as the only channel for that package. When ChannelPriority.Disabled it will search for every package in every channel.

Strict
timeout Optional[timedelta]

The maximum time the solver is allowed to run.

None
exclude_newer Optional[datetime]

Exclude any record that is newer than the given datetime.

None
strategy SolveStrategy

The strategy to use when multiple versions of a package are available.

  • "highest": Select the highest compatible version of all packages.
  • "lowest": Select the lowest compatible version of all packages.
  • "lowest-direct": Select the lowest compatible version for all direct dependencies but the highest compatible version of transitive dependencies.
'highest'
constraints Optional[Sequence[MatchSpec | str]]

Additional constraints that should be satisfied by the solver. Packages included in the constraints are not necessarily installed, but they must be satisfied by the solution.

None

Returns:

Type Description
List[RepoDataRecord]

Resolved list of RepoDataRecords.