\hIdZddlZddlmZddlmZmZmZmZm Z m Z m Z ddl m Z ddlmZe e ege effZereeZneZdeed eefd Zd edeed eefd Zd edeed eefd ZGddeZy)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) Candidateinfosreturnc#|Kt}|D])\}}||vr |}|||j|+yw)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)rversions_foundversionfunc candidates w/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py _iter_builtr%sP ),N$  n $ F   7#$s:< installedc#K||jh}|D])\}}||vr |}|||j|+yw)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)rrrrrrrrs r_iter_built_with_prependedr6s\ O)2):):(;N$  n $ F   7#$sAAc#Kt}|D]W\}}||vr |j|k\r||j|j|}|C||j|Y|j|vr|yyw)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)rrrrs r_iter_built_with_insertedrLs),N $  n $     'O   y00 1F   7# $./sA;A=c eZdZdZdegeefdeede de e fdZ de de fd Zdeefd Zde fd Zej$d de fdZy)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_idsc<||_||_||_||_yN) _get_infos _installed_prefers_installed_incompatible_ids)selfr!rr"r#s r__init__zFoundCandidates.__init__us"$#"3!1indexrctdNz don't do thisNotImplementedError)r*r-s r __getitem__zFoundCandidates.__getitem__"/22r,cj}js t|}n9jrt j|}nt j|}fd|DS)Nc3RK|]}t|jvs| ywr%)idr)).0cr*s r z+FoundCandidates.__iter__..s"Kar!uD4J4J'JKs'')r&r'rr(rr)r*riterators` r__iter__zFoundCandidates.__iter__sT!"5)H  $ $1$//5IH0%HHK8KKr,ctdr/r0r*s r__len__zFoundCandidates.__len__r3r,r )maxsizecJ|jr |jryt|S)NT)r(r'anyr=s r__bool__zFoundCandidates.__bool__s  " "t4yr,N)__name__ __module__ __qualname____doc__rrIndexCandidateInforr boolr intr+rr2r;r> functools lru_cacherBr,rr r ls 2B); <<= 2I& 2 2 c( 2333 L(9-L33 Y#$$r,r )rFrJcollections.abcrtypingrrrrrr r pip._vendor.packaging.versionr baser rGSequenceCandidaterrrr rLr,rrRs$OOO6<"hy6I2I)JJK +!$x 23$8K$"$$!)*