diff --git a/news/3235.misc.md b/news/3235.misc.md new file mode 100644 index 0000000000..68ff6a5b66 --- /dev/null +++ b/news/3235.misc.md @@ -0,0 +1 @@ +Update `resolvelib` to 1.1.0. diff --git a/pdm.lock b/pdm.lock index 24f36dc4b2..51731e4ce0 100644 --- a/pdm.lock +++ b/pdm.lock @@ -1999,12 +1999,13 @@ files = [ [[package]] name = "resolvelib" -version = "1.0.1" +version = "1.1.0" +requires_python = ">=3.7" summary = "Resolve abstract dependencies into concrete ones" groups = ["default"] files = [ - {file = "resolvelib-1.0.1-py2.py3-none-any.whl", hash = "sha256:d2da45d1a8dfee81bdd591647783e340ef3bcb104b54c383f70d422ef5cc7dbf"}, - {file = "resolvelib-1.0.1.tar.gz", hash = "sha256:04ce76cbd63fded2078ce224785da6ecd42b9564b1390793f64ddecbe997b309"}, + {file = "resolvelib-1.1.0-py2.py3-none-any.whl", hash = "sha256:f80de38ae744bcf4e918e27a681a5c6cb63a08d9a926c0989c0730bcdd089049"}, + {file = "resolvelib-1.1.0.tar.gz", hash = "sha256:b68591ef748f58c1e2a2ac28d0961b3586ae8b25f60b0ba9a5e4f3d87c1d6a79"}, ] [[package]] diff --git a/src/pdm/resolver/providers.py b/src/pdm/resolver/providers.py index af8243932b..e14a3bf974 100644 --- a/src/pdm/resolver/providers.py +++ b/src/pdm/resolver/providers.py @@ -46,7 +46,7 @@ def wrapper(cls: ProviderT) -> ProviderT: @register_provider("all") -class BaseProvider(AbstractProvider): +class BaseProvider(AbstractProvider[Requirement, Candidate, str]): def __init__( self, repository: BaseRepository, @@ -71,7 +71,6 @@ def __init__( self.excludes = {normalize_name(k) for k in project.pyproject.resolution.get("excludes", [])} self.direct_minimal_versions = direct_minimal_versions self.locked_candidates = locked_candidates - self._known_depth: dict[str, int] = {} def requirement_preference(self, requirement: Requirement) -> Comparable: """Return the preference of a requirement to find candidates. @@ -102,14 +101,6 @@ def get_preference( backtrack_identifiers = {req.identify() for req, _ in backtrack_causes} | { parent.identify() for _, parent in backtrack_causes if parent is not None } - if is_top: - dep_depth = 1 - else: - parent_depths = ( - self._known_depth[parent.identify()] if parent is not None else 0 - for _, parent in information[identifier] - ) - dep_depth = min(parent_depths, default=0) + 1 # Use the REAL identifier as it may be updated after candidate preparation. deps: list[Requirement] = [] for candidate in candidates[identifier]: @@ -118,7 +109,6 @@ def get_preference( except RequirementsConflicted: continue break - self._known_depth[self.identify(candidate)] = dep_depth is_backtrack_cause = any(dep.identify() in backtrack_identifiers for dep in deps) is_file_or_url = any(not requirement.is_named for requirement, _ in information[identifier]) operators = [spec.operator for req, _ in information[identifier] for spec in req.specifier] @@ -131,7 +121,6 @@ def get_preference( not is_file_or_url, not is_pinned, not is_backtrack_cause, - dep_depth, -constraints, identifier, )