a ljI@sdZddlZddlmZddlmZmZmZmZm Z m Z m Z ddl m Z ddlmZe e ege effZerzeeZneZeeeedd d Zeeeeed d d Zeeeeed ddZGdddeZdS)aUtilities to lazily create and visit candidates found. Creating and visiting a candidate is a *very* costly operation. It involves fetching, extracting, potentially building modules from source, and verifying distribution metadata. It is therefore crucial for performance to keep everything here lazy all the way down, so we only touch candidates that we absolutely need, and not "download the world" when we only need one version of something. N)Sequence) TYPE_CHECKINGAnyCallableIteratorOptionalSetTuple) _BaseVersion) Candidate)infosreturnccsBt}|D]2\}}||vrq |}|dur,q |V||q dS)zIterator for ``FoundCandidates``. This iterator is used when the package is not already installed. Candidates from index come later in their normal ordering. N)setadd)r versions_foundversionfunc candidaterX/usr/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py _iter_built%s r) installedr rccsJ|V|jh}|D]2\}}||vr$q|}|dur4q|V||qdS)aKIterator for ``FoundCandidates``. This iterator is used when the resolver prefers the already-installed candidate and NOT to upgrade. The installed candidate is therefore always yielded first, and candidates from index come later in their normal ordering, except skipped when the version is already installed. N)rrrr rrrrrrr_iter_built_with_prepended6s  rccsnt}|D]N\}}||vrq |j|kr8|V||j|}|durHq |V||q |j|vrj|VdS)aIterator for ``FoundCandidates``. This iterator is used when the resolver prefers to upgrade an already-installed package. Candidates from index are returned in their normal ordering, except replaced when the version is already installed. The implementation iterates through and yields other candidates, inserting the installed candidate exactly once before we start yielding older or equivalent candidates, or after all other candidates if they are all newer. N)rrrrrrr_iter_built_with_insertedLs      rc@seZdZdZegeefeee e e dddZ e e dddZeedd d Ze dd d Zejd de dddZdS)FoundCandidatesacA lazy sequence to provide candidates to the resolver. The intended usage is to return this from `find_matches()` so the resolver can iterate through the sequence multiple times, but only access the index page when remote packages are actually needed. This improve performances when suitable candidates are already installed on disk. ) get_infosrprefers_installedincompatible_idscCs||_||_||_||_dSN) _get_infos _installed_prefers_installed_incompatible_ids)selfrrrrrrr__init__uszFoundCandidates.__init__)indexrcCs tddSNz don't do thisNotImplementedError)r%r'rrr __getitem__szFoundCandidates.__getitem__)rcsJ}jst|}n jr,tj|}n tj|}fdd|DS)Nc3s |]}t|jvr|VqdSr )idr$).0cr%rr z+FoundCandidates.__iter__..)r!r"rr#rr)r%r iteratorrr/r__iter__s  zFoundCandidates.__iter__cCs tddSr(r)r/rrr__len__szFoundCandidates.__len__r )maxsizecCs|jr|jrdSt|S)NT)r#r"anyr/rrr__bool__s zFoundCandidates.__bool__N)__name__ __module__ __qualname____doc__rrIndexCandidateInforr boolrintr&rr+r3r4 functools lru_cacher7rrrrrls    r)r;r?collections.abcrtypingrrrrrrr Zpip._vendor.packaging.versionr baser r<ZSequenceCandidaterrrrrrrrs"  $