conda.api.Solver

class conda.core.solve.DepsModifier

Flags to enable alternate handling of dependencies.

NOT_SET = 'not_set'
NO_DEPS = 'no_deps'
ONLY_DEPS = 'only_deps'
class conda.core.solve.Solver(prefix, channels, subdirs=(), specs_to_add=(), specs_to_remove=(), repodata_fn='repodata.json')

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

Gives the final, solved state of the environment.

Parameters
  • update_modifier (UpdateModifier) -- An optional flag directing how updates are handled regarding packages already existing in the environment.

  • 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=<auxlib._Null object>, deps_modifier=<auxlib._Null object>, prune=<auxlib._Null object>, ignore_pinned=<auxlib._Null object>, force_remove=<auxlib._Null object>, force_reinstall=<auxlib._Null object>)

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]

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=<auxlib._Null object>)

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

Parameters
Returns

Return type

UnlinkLinkTransaction