
    Qh]                    H   U d dl mZ d dlZd dlZd dlZd dlmZmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZmZ ddlmZ dd	lmZmZmZmZmZ erd d
lmZmZm Z  ddl!m"Z"m#Z# ddl$m%Z% dZ&de'd<   ddZ( G d deee	e
f         Z) G d deee	e
f         Z*	 	 	 	 	 	 	 	 	 	 ddZ+y)    )annotationsN)TYPE_CHECKINGGeneric   )	CTKTRTDirectedGraphIterableViewIteratorMappingRequirementInformationStatebuild_iter_view   )AbstractResolverResult)	Criterion)InconsistentCandidateRequirementsConflictedResolutionImpossibleResolutionTooDeepResolverException)
CollectionIterableMapping)AbstractProvider
Preference)BaseReporterg?float_OPTIMISTIC_BACKJUMPING_RATIOc                   | j                   }|j                         D ci c]  \  }}t        |      | }}}d |t        d       <   t               }|j	                  d        d h}| j
                  j                         D ]~  \  }}t        | j
                  |||      s||vr|j	                  |       |j                         D ]8  }		 |t        |	         }
|
|vr|j	                  |
       |j                  |
|       :  t        |j                         D ci c]  \  }}||v s|| c}}|| j
                        S c c}}w # t        $ r Y w xY wc c}}w )N)mappinggraphcriteria)r"   itemsidr
   addr$   _has_route_to_rootiter_parentKeyErrorconnectr   )stater"   kvall_keysr#   	connectedkey	criterionppkeys              g/var/www/teggl/fontify/venv/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers/resolution.py_build_resultr6   &   sF   mmG;B==?%K41abeQh%KH%KHRX&3oE	IIdO!%I....0 %Y!%..#xKeIIcN&&( 	%A1 5 		$MM$$	%% ")--/D$!QQ)^AD + &L   Es#   D?EE
%E
	EEc                      e Zd ZdZ	 	 	 	 	 	 ddZedd       ZddZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ	ddZ
	 	 	 	 	 	 ddZdd	Zdd
Z	 	 	 	 ddZddZddZddZ	 	 	 	 ddZddZy)
ResolutionzStateful resolution object.

    This is designed as a one-off object that holds information to kick start
    the resolution process, and holds the results afterwards.
    c                `    || _         || _        g | _        t        | _        d | _        d | _        y N)_p_r_statesr    _optimistic_backjumping_ratio_save_states_optimistic_start_round)selfproviderreporters      r5   __init__zResolution.__init__K   s4    
 02 .K*<@37$    c                \    	 | j                   d   S # t        $ r}t        d      |d }~ww xY w)Nr,   )r=   
IndexErrorAttributeError)rA   es     r5   r,   zResolution.stateY   s3    	1<<## 	1 )q0	1s    	+&+c                    | j                   d   }t        |j                  j                         |j                  j                         |j
                  dd       }| j                   j                  |       y)zPush a new state into history.

        This new state will be used to hold resolution results of the next
        coming round.
        rG   Nr"   r$   backtrack_causes)r=   r   r"   copyr$   rM   append)rA   baser,   s      r5   _push_new_statezResolution._push_new_state`   s^     ||BLL%%']]'')!2215

 	E"rE   c           
     p   | j                   j                  ||       | j                  j                  |      }|j	                  |      }|rt        |j                        }ng }| j                  j                  |t        |t        j                  d      ||gi      t        |t        j                  d      ||i            }|r1t        |j                        }|j                  t        ||             nt        ||      g}t        t!        |      ||      }|j"                  st%        |      |||<   y )N)requirementparent)requirement_or_candidateiter_requirementincompatibilities
identifierrequirementsrW   
candidatesinformationrW   )r<   adding_requirementr;   identifygetlistrW   find_matchesr   operatormethodcaller
attrgetterr]   rO   r   r   r   r\   r   )	rA   r$   rS   rT   rY   r2   rW   matchesr]   s	            r5   _add_to_criteriazResolution._add_to_criterian   s1    	""{6"JWW%%{%K
LL,	 $Y%@%@ A "''&&!(%%&89k]+
 .##$78./ ' 
 y445K5k6JK1+vFGK&w/#/
	
 ##(33(rE   c           
     "   |sy|j                         D ]t  \  }}t        |j                  |j                  D cg c]7  }|j                  '| j
                  j                  |j                        |vr|9 c}|j                        ||<   v yc c}w )aW  Remove information from parents of criteria.

        Concretely, removes all values from each criterion's ``information``
        field that have one of ``parents`` as provider of the requirement.

        :param criteria: The criteria to update.
        :param parents: Identifiers for which to remove information from all criteria.
        N)r%   r   r\   r]   rT   r;   r_   rW   )rA   r$   parentsr1   r2   r]   s         r5   !_remove_information_from_criteriaz,Resolution._remove_information_from_criteria   s     &nn. 	NC%$$ (1'<'<##**277++K,>,>?wN	   ++HSM	s   <Bc                V   | j                   j                  || j                  j                  t	        | j                  j
                  t        j                  d            t	        | j                  j
                  t        j                  d            | j                  j                        S )Nr\   r]   )rY   resolutionsr\   r]   rM   )	r;   get_preferencer,   r"   r   r$   rc   re   rM   )rA   names     r5   _get_preferencezResolution._get_preference   s    ww%%

**&

####L1 (

####M2 "ZZ88 & 
 	
rE   c                     	  j                   j                  |   t         fd|j	                         D              S # t        $ r Y yw xY w)NFc              3  X   K   | ]!  }j                   j                  |        # yw)rS   	candidateNr;   is_satisfied_by).0rcurrent_pinrA   s     r5   	<genexpr>z8Resolution._is_current_pin_satisfying.<locals>.<genexpr>   s-      
 GG##[#I
   '*)r,   r"   r*   allrV   )rA   rn   r2   rx   s   `  @r5   _is_current_pin_satisfyingz%Resolution._is_current_pin_satisfying   sU    	**,,T2K  
//1
 
 	
  		s   A   	AAc                    | j                   j                  j                         }| j                  j	                  |      D ]  }| j                  |||        |S )Nrs   rT   )r,   r$   rN   r;   get_dependenciesrg   )rA   rs   r$   rS   s       r5   _get_updated_criteriaz Resolution._get_updated_criteria   sW    ::&&++-7733i3H 	KK!!(K	!J	KrE   c                     j                   j                  |   }g }|j                  D ]  	  j                        }t         fd|j                         D              }|st        |       j
                  j                          j                   j                  j                  |        j                   j                  j                  |d         j                   j                  |<   g c S  |S # t        $ rL} j
                  j                  |j                         |j                  |j                         Y d }~d }~ww xY w)Nc              3  X   K   | ]!  }j                   j                  |        # ywrr   rt   )rv   rw   rs   rA   s     r5   ry   z7Resolution._attempt_to_pin_criterion.<locals>.<genexpr>   s-       ''A'Krz   r~   )r,   r$   r\   r   r   r<   rejecting_candidater2   rO   r{   rV   r   pinningupdater"   pop)rA   rn   r2   causesr$   rJ   	satisfiedrs   s   `      @r5   _attempt_to_pin_criterionz$Resolution._attempt_to_pin_criterion   s   JJ''-	*,"-- 	I55i@  "335 I +IyAAGGOOiO0JJ&&x0 JJ""4.'0DJJt$I7	> 9 * ++AKKCakk*s   C77	E AEEc                @   |D ]  \  }}|s
	 | j                   j                  |   }| j                  j	                  |t        | j                   j                  t        j                  d            t        | j                   j                  t        j                  d      ||i            }t        |      }|s y|j                  |j                         t        |t        |j                        |      | j                   j                  |<    y# t        $ r Y w xY w)NrV   rW   rX   Fr[   T)r,   r$   r*   r;   rb   r   rc   rd   re   r   extendrW   r   ra   r]   )rA   incompatibilities_from_brokenr-   rW   r2   rf   r\   s          r5   _patch_criteriazResolution._patch_criteria   s   
 %B 	 A $ JJ//2	 gg**,JJ''))*<= #2JJ''''(;<)*# + G ,;7+CJ$$Y%@%@A%.% !6!67"3&DJJ"/	8 /  s   D	DDc           
         | j                   i| j                  D cg c]M  }t        |j                  j	                         |j
                  j	                         |j                  dd       O c}| _         yyc c}w )zCSave states for potential rollback if optimistic backjumping fails.NrL   )r?   r=   r   r"   rN   r$   rM   )rA   ss     r5   _save_statezResolution._save_state  sj    $ !  IINN,ZZ__.%&%7%7%:!D %!s   AA7c                \    d| _         | j                  r| j                  | _        d| _        yy)z3Rollback states and disable optimistic backjumping.g        N)r>   r?   r=   )rA   s    r5   _rollback_stateszResolution._rollback_states*  s-    -0*,,DL $D rE   c                2   t        j                  d |D        d |D              }|D ch c]  }| j                  j                  |       }}t	        | j
                        dk\  r| j
                  d= | j                  }	 	 | j
                  j                         }|j                  j                         \  }}| j                  s||vrn| j                  r | j                  ||vr| j                          | j                  j!                  |      D ch c]  }| j                  j                  |       }	}|	j#                  |      sn|j                  sn|j$                  j'                         D 
cg c]  \  }
}|
t)        |j*                        f }}
}|j-                  ||gf       | j/                          | j1                  |      }|ryt	        | j
                        dk\  ryc c}w # t        t        f$ r t        |      dw xY wc c}w c c}}
w )a2  Perform backjumping.

        When we enter here, the stack is like this::

            [ state Z ]
            [ state Y ]
            [ state X ]
            .... earlier states are irrelevant.

        1. No pins worked for Z, so it does not have a pin.
        2. We want to reset state Y to unpinned, and pin another candidate.
        3. State X holds what state Y was before the pin, but does not
           have the incompatibility information gathered in state Y.

        Each iteration of the loop will:

        1.  Identify Z. The incompatibility is not always caused by the latest
            state. For example, given three requirements A, B and C, with
            dependencies A1, B1 and C1, where A1 and B1 are incompatible: the
            last state might be related to C, so we want to discard the
            previous state.
        2.  Discard Z.
        3.  Discard Y but remember its incompatibility information gathered
            previously, and the failure we're dealing with right now.
        4.  Push a new state Y' based on X, and apply the incompatibility
            information from Y to Y'.
        5a. If this causes Y' to conflict, we need to backtrack again. Make Y'
            the new Z and go back to step 2.
        5b. If the incompatibilities apply cleanly, end backtracking.
        c              3  N   K   | ]  }|j                   |j                     y wr:   r   rv   cs     r5   ry   z'Resolution._backjump.<locals>.<genexpr>Q  s     >!)=QXX>s   %%c              3  4   K   | ]  }|j                     y wr:   )rS   r   s     r5   ry   z'Resolution._backjump.<locals>.<genexpr>R  s     +qQ]]+s      rG   TNF)	itertoolschainr;   r_   lenr=   r,   r   r"   popitemrH   r*   r   r>   r?   r   r   
isdisjointr$   r%   ra   rW   rO   rQ   r   )rA   r   incompatible_reqsrw   incompatible_depsbroken_statern   rs   dcurrent_dependenciesr-   r.   r   successs                 r5   	_backjumpzResolution._backjump1  s   > 09>v>+F+0
 ;LLQTWW--a0LL$,,1$R   ::LA#'<<#3#3#5L&2&:&:&B&B&DOD)
 ::$55 
 66))1$55$$& 261I1I)1T(,-DGG$$Q'($ ( ,667HI
 $++M R <H;P;P;V;V;X-371aD,,-.-) -
 *00$1DE  "**+HIG u $,,1$@ C M #H- A.v6D@A.(-s   "G*7G/ "H3!H/Hc           
         t        |D ci c]  }|j                  D ]  }t        |      | ! c}}j                               S c c}}w )z5Extract causes from list of criterion and deduplicate)ra   r]   r&   values)rA   criteronr   is       r5   _extract_causeszResolution._extract_causes  s>     xG!GARUAXGUGNNPQQGs   $A
c                	   | j                   rt        d      | j                  j                          t	        t        j                         i g       g| _         |D ]+  }	 | j                  | j                  j                  |d        - | j                          d }d }t        |      D ]  }| j                  j!                  |       | j"                  r\| j$                  P|3|}t'        ||z
  | j"                  z        }|dk  r,| j)                          m|||z
  |k\  r| j)                          | j                  j                  j+                         D 	cg c]  \  }}	| j-                  ||	      s| }
}}	|
s4| j                  j/                  | j                         | j                  c S t1        | j                  j                  j3                               t1        |
      z
  }t5        |
      dkD  rt7        | j8                  j;                  |
| j                  j<                  t?        | j                  j                  tA        jB                  d            t?        | j                  j                  tA        jB                  d	            | j                  jD                  
            }n|
}|st        d      t5        |      dkD  rtG        || jH                        }n|d   }| jK                  |      }|r| jM                  |      }| j                  jO                  |       	 | jQ                  |      }tS        | xr | j"                  xr | j$                        }|r| j$                  r| j)                          n|| j                  jD                  d d  st        | j                  jD                        | j                  j                  j+                         D 	ch c]  \  }}	||v r| j-                  ||	      s| }}}	| jU                  | j                  j                  |       | j                          | j                  jW                  || j                          tY        |      # t        $ r%}t        |j                  j                        |d }~ww xY wc c}	}w # t        $ r  | j"                  r| j$                  rd}n Y ow xY wc c}	}w )Nzalready resolvedrL   r   )indexr   )r,   r   r\   r]   )identifiersrl   r\   r]   rM   z-narrow_requirement_selection returned 0 names)r1   )r   T)r   r,   )-r=   RuntimeErrorr<   startingr   collectionsOrderedDictrg   r,   r$   r   r   r2   r]   rQ   rangestarting_roundr>   r?   intr   r%   r|   endingsetkeysr   ra   r;   narrow_requirement_selectionr"   r   rc   re   rM   minro   r   r   resolving_conflictsr   boolrj   ending_roundr   )rA   rZ   
max_roundsrw   rJ   optimistic_rounds_cutoff"optimistic_backjumping_start_roundround_indexr1   r2   unsatisfied_namessatisfied_namesnarrowed_unstatisfied_namesrn   failure_criterionr   r   failed_optimistic_backjumpingnewly_unsatisfied_namess                      r5   resolvezResolution.resolve  s   <<122 #//1!#
  	KAK%%djj&9&91T%J	K 	 04 9=* , o	FKGG"""5 11d6G6G6S5=9D6/2#k1T5W5WW0, 014--/ -9#&HH34 --/  '+jj&9&9&?&?&A!"C66sIF ! ! %TZZ0zz! "$**"5"5":":"<=DU@VVO$%).2GG88$5$(JJ$6$6#2 JJ//$//=$ %4 JJ//$//>% *.)D)D 9 /+  /@+ /"#RSS ./!36D<P<PQ215 $ > >t D --.?@ ++6+:"nnV4G 59# . >>. --51 1T5F5F))+5;DJJ//2 #24::3N3NOO +/***=*=*C*C*E+&Yo- ;;CK +' + 66JJ'')@ $$&GG  {$** E_o	Fb  
++{ * K*1;;+B+BCJKD!l , 99d>O>O8<5 6.+s6   (Q,R#R#"S,	R5 RR#%SSN)rB   zAbstractProvider[RT, CT, KT]rC   zBaseReporter[RT, CT, KT]returnNone)r   State[RT, CT, KT])r   r   )r$   dict[KT, Criterion[RT, CT]]rS   r	   rT   z	CT | Noner   r   )r$   r   ri   zCollection[KT]r   r   )rn   r   r   r   )rn   r   r2   zCriterion[RT, CT]r   r   )rs   r   r   r   )rn   r   r   list[Criterion[RT, CT]])r   zlist[tuple[KT, list[CT]]]r   r   )r   $list[RequirementInformation[RT, CT]]r   r   )r   r   r   r   )rZ   Iterable[RT]r   r   r   r   )__name__
__module____qualname____doc__rD   propertyr,   rQ   rg   rj   ro   r|   r   r   r   r   r   r   r   r    rE   r5   r8   r8   D   s    8.8 +8 
	8 1 1#*)-*) *) 	*)
 
*)X3>L	6




#4

	

#J!-F!	!F
%dLR/R	-RN,rE   r8   c                  *    e Zd ZdZeZ	 d	 	 	 	 	 ddZy)Resolverz3The thing that performs the actual resolution work.c                ~    t        | j                  | j                        }|j                  ||      }t	        |      S )a  Take a collection of constraints, spit out the resolution result.

        The return value is a representation to the final resolution result. It
        is a tuple subclass with three public members:

        * `mapping`: A dict of resolved candidates. Each key is an identifier
            of a requirement (as returned by the provider's `identify` method),
            and the value is the resolved candidate.
        * `graph`: A `DirectedGraph` instance representing the dependency tree.
            The vertices are keys of `mapping`, and each edge represents *why*
            a particular package is included. A special vertex `None` is
            included to represent parents of user-supplied requirements.
        * `criteria`: A dict of "criteria" that hold detailed information on
            how edges in the graph are derived. Each key is an identifier of a
            requirement, and the value is a `Criterion` instance.

        The following exceptions may be raised if a resolution cannot be found:

        * `ResolutionImpossible`: A resolution cannot be found for the given
            combination of requirements. The `causes` attribute of the
            exception is a list of (requirement, parent), giving the
            requirements that could not be satisfied.
        * `ResolutionTooDeep`: The dependency tree is too deeply nested and
            the resolver gave up. This is usually caused by a circular
            dependency, but you can try to resolve this by increasing the
            `max_rounds` argument.
        )r   )r8   rB   rC   r   r6   )rA   rZ   r   
resolutionr,   s        r5   r   zResolver.resolve3  s9    @  t}}=
""<J"GU##rE   N)d   )rZ   r   r   r   r   Result[RT, CT, KT])r   r   r   r   r   base_exceptionr   r   rE   r5   r   r   .  s0    =&N
 "$""$ "$ 
	"$rE   r   c                    ||v ry|| vry|J | |   j                         D ]I  }	 |t        |         }||v r|j                  |        yt	        | |||      s8|j                  |        y y# t        $ r Y Xw xY w)NTF)r)   r&   r*   r'   r(   )r$   r1   r/   r0   r3   r4   s         r5   r(   r(   X  s     i
(??c]&&( 
	BqE?D 9MM#hh	BMM#
   		s   A//	A;:A;)r,   r   r   r   )
r$   zMapping[KT, Criterion[RT, CT]]r1   z	KT | Noner/   zdict[int, KT | None]r0   zset[KT | None]r   r   ),
__future__r   r   r   rc   typingr   r   structsr   r   r	   r
   r   r   r   r   r   abstractr   r   r2   r   
exceptionsr   r   r   r   r   collections.abcr   r   r   	providersr   r   	reportersr   r    __annotations__r6   r8   r   r(   r   rE   r5   <module>r      s    "    )
 
 
 /    ==8('* u *<g,R$ g,T'$B
+ '$T,	 # 	
 
rE   