Dependency resolution (source code)

= Dependency resolution

<Dependency resolution> chooses compatible <software package> versions and their transitive requirements for a requested installation. It is a <constraint satisfaction problem>: choosing a version can introduce additional requirements, which may invalidate choices made earlier. Pip uses <backtracking> to reconsider such choices.<Dependency Resolution in the pip documentation>[How it works, Backtracking and Dealing with dependency conflicts]{ref}

If $A$ requires library $L$ at version at least 2 but below 4, and $B$ requires $L$ at least 3 but below 5, the shared allowed interval is versions at least 3 but below 4. If $B$ instead requires at least 4, no single version satisfies both. Downloading more candidates cannot remove that contradiction. Recording the selected versions preserves a solution to those constraints; it does not by itself record all execution conditions.