MCPcopy
hub / github.com/jazzband/pip-tools / resolve

Method resolve

piptools/resolver.py:245–295  ·  view source on GitHub ↗

r""" Find concrete package versions for all the given ``InstallRequirement``\ s and their recursive dependencies and return a set of pinned ``InstallRequirement``\ s. Resolves constraints one round at a time, until they don't change anymore. :param m

(self, max_rounds: int = 10)

Source from the content-addressed store, hash-verified

243 )
244
245 def resolve(self, max_rounds: int = 10) -> set[InstallRequirement]:
246 r"""
247 Find concrete package versions for all the given ``InstallRequirement``\ s
248 and their recursive dependencies and return a set of pinned
249 ``InstallRequirement``\ s.
250
251 Resolves constraints one round at a time, until they don't change
252 anymore.
253
254 :param max_rounds: break out of resolution process after the given number of rounds
255 to prevent infinite loops (default is 10)
256 """
257 if self.clear_caches:
258 self.dependency_cache.clear()
259 self.repository.clear_caches()
260
261 # Ignore existing packages
262 with update_env_context_manager(PIP_EXISTS_ACTION="i"):
263 for current_round in count(start=1): # pragma: no branch
264 if current_round > max_rounds:
265 raise RuntimeError(
266 "No stable configuration of concrete packages "
267 "could be found for the given constraints after "
268 "{max_rounds} rounds of resolving.\n"
269 "This is likely a bug.".format(max_rounds=max_rounds)
270 )
271
272 log.debug("")
273 log.debug(magenta(f"{f'ROUND {current_round}':^60}"))
274 has_changed, best_matches = self._resolve_one_round()
275 log.debug("-" * 60)
276 log.debug(
277 "Result of round {}: {}".format(
278 current_round,
279 "not stable" if has_changed else "stable, done",
280 )
281 )
282 if not has_changed:
283 break
284
285 # Only include hard requirements and not pip constraints
286 results = {req for req in best_matches if not req.constraint}
287
288 # Filter out unsafe requirements.
289 if not self.allow_unsafe:
290 self._filter_out_unsafe_constraints(
291 ireqs=results,
292 unsafe_packages=self.unsafe_packages,
293 )
294
295 return results
296
297 def _group_constraints(
298 self, constraints: Iterable[InstallRequirement]

Callers

nothing calls this directly

Calls 5

_resolve_one_roundMethod · 0.95
clearMethod · 0.80
debugMethod · 0.80
clear_cachesMethod · 0.45

Tested by

no test coverage detected