piptools.resolver module#
- class piptools.resolver.BacktrackingResolver(constraints: Iterable[InstallRequirement], existing_constraints: dict[str, InstallRequirement], repository: BaseRepository, allow_unsafe: bool = False, unsafe_packages: set[str] | None = None, **kwargs: Any)#
Bases:
BaseResolver
A wrapper for the backtracking (or 2020) resolver.
- _abc_impl = <_abc._abc_data object>#
- _do_resolve(resolver: Resolver, compatible_existing_constraints: dict[str, InstallRequirement]) bool #
Resolve dependencies based on resolvelib
Resolver
.
- _get_install_requirement_from_candidate(candidate: Candidate, reverse_dependencies: dict[str, set[str]]) InstallRequirement | None #
- class piptools.resolver.BaseResolver#
Bases:
object
- _abc_impl = <_abc._abc_data object>#
- _filter_out_unsafe_constraints(ireqs: set[InstallRequirement], unsafe_packages: Container[str]) None #
Remove from a given set of
InstallRequirement
s unsafe constraints.
- repository: BaseRepository#
- abstract resolve(max_rounds: int) set[InstallRequirement] #
Find concrete package versions for all the given InstallRequirements and their recursive dependencies. :returns: a set of pinned
InstallRequirement
s.
- class piptools.resolver.LegacyResolver(constraints: Iterable[InstallRequirement], existing_constraints: dict[str, InstallRequirement], repository: BaseRepository, cache: DependencyCache, prereleases: bool | None = False, clear_caches: bool = False, allow_unsafe: bool = False, unsafe_packages: set[str] | None = None)#
Bases:
BaseResolver
Wrapper for the (deprecated) legacy dependency resolver.
- _abc_impl = <_abc._abc_data object>#
- _group_constraints(constraints: Iterable[InstallRequirement]) Iterator[InstallRequirement] #
Group constraints (remember, InstallRequirements!) by their key name.
Then combine their SpecifierSets into a single InstallRequirement per package. For example, given the following constraints:
Django<1.9,>=1.4.2 django~=1.5 Flask~=0.7
This will be combined into a single entry per package:
django~=1.5,<1.9,>=1.4.2 flask~=0.7
- _ireqs_of_dependencies(ireq: InstallRequirement, dependency_strings: list[str]) Iterator[InstallRequirement] #
- _iter_dependencies(ireq: InstallRequirement) Iterator[InstallRequirement] #
Emit all secondary dependencies for an ireq.
Given a pinned, url, or editable InstallRequirement, collects all the secondary dependencies for them, either by looking them up in a local cache, or by reaching out to the repository.
Editable requirements will never be looked up, as they may have changed at any time.
- _resolve_one_round() tuple[bool, set[InstallRequirement]] #
Resolve one level of the current constraints.
This is achieved by finding the best match for each package in the repository and adding all requirements for those best package versions. Some of these constraints may be new or updated.
- Returns:
whether new constraints appeared in this round. If no constraints were added or changed, this indicates a stable configuration.
- get_best_match(ireq: InstallRequirement) InstallRequirement #
Return a (pinned or editable) InstallRequirement.
This indicates the best match to use for the given InstallRequirement (in the form of an InstallRequirement).
Example: Given the constraint Flask>=0.10, may return Flask==0.10.1 at a certain moment in time.
Pinned requirements will always return themselves, i.e.
Flask==0.10.1 => Flask==0.10.1
- resolve(max_rounds: int = 10) set[InstallRequirement] #
Find concrete package versions for all the given
InstallRequirement
s and their recursive dependencies and return a set of pinnedInstallRequirement
s.Resolves constraints one round at a time, until they don’t change anymore.
- Parameters:
max_rounds – break out of resolution process after the given number of rounds to prevent infinite loops (default is 10)