ó
Ð²Ebc           @   sJ  d  d l  Z  d d l m Z d d l m Z m Z e  j d d d g ƒ Z d e f d	 „  ƒ  YZ	 d
 e	 f d „  ƒ  YZ
 d e	 f d „  ƒ  YZ d e f d „  ƒ  YZ d e	 f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e  j d d ƒ Z d e f d „  ƒ  YZ d „  Z e  j d d ƒ Z d „  Z d e f d „  ƒ  YZ d S(    iÿÿÿÿNi   (   t   AbstractResolver(   t   DirectedGrapht   build_iter_viewt   RequirementInformationt   requirementt   parentt   ResolverExceptionc           B   s   e  Z d  Z RS(   sÆ   A base class for all exceptions raised by this module.

    Exceptions derived by this class should all be handled in this module. Any
    bubbling pass the resolver should be treated as a bug.
    (   t   __name__t
   __module__t   __doc__(    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR      s   t   RequirementsConflictedc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s#   t  t |  ƒ j | ƒ | |  _ d  S(   N(   t   superR
   t   __init__t	   criterion(   t   selfR   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR      s    c         C   s)   d j  d j d „  |  j j ƒ  Dƒ ƒ ƒ S(   Ns   Requirements conflict: {}s   , c         s   s   |  ] } t  | ƒ Vq d  S(   N(   t   repr(   t   .0t   r(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys	   <genexpr>   s    (   t   formatt   joinR   t   iter_requirement(   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   __str__   s    (   R   R   R   R   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR
      s   	t   InconsistentCandidatec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s/   t  t |  ƒ j | | ƒ | |  _ | |  _ d  S(   N(   R   R   R   t	   candidateR   (   R   R   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR       s    	c         C   s/   d j  |  j d j d „  |  j j ƒ  Dƒ ƒ ƒ S(   Ns+   Provided candidate {!r} does not satisfy {}s   , c         s   s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys	   <genexpr>(   s    (   R   R   R   R   R   (   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR   %   s    (   R   R   R   R   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR      s   	t	   Criterionc           B   sS   e  Z d  Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   sQ  Representation of possible resolution results of a package.

    This holds three attributes:

    * `information` is a collection of `RequirementInformation` pairs.
      Each pair is a requirement contributing to this criterion, and the
      candidate that provides the requirement.
    * `incompatibilities` is a collection of all known not-to-work candidates
      to exclude from consideration.
    * `candidates` is a collection containing all possible candidates deducted
      from the union of contributing requirements and known incompatibilities.
      It should never be empty, except when the criterion is an attribute of a
      raised `RequirementsConflicted` (in which case it is always empty).

    .. note::
        This class is intended to be externally immutable. **Do not** mutate
        any of its attribute containers.
    c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t
   candidatest   informationt   incompatibilities(   R   R   R   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR   @   s    		c         C   s)   d j  d „  |  j Dƒ ƒ } d j | ƒ S(   Ns   , c         s   s'   |  ] \ } } d  j  | | ƒ Vq d S(   s   ({!r}, via={!r})N(   R   (   R   t   reqR   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys	   <genexpr>G   s   s   Criterion({})(   R   R   R   (   R   t   requirements(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   __repr__E   s    c         C   sX   t  | j | g ƒ ƒ } t | | ƒ g } |  | | d g  ƒ} | sT t | ƒ ‚ n  | S(   s%   Build an instance from a requirement.R   (   R   t   find_matchesR   R
   (   t   clst   providerR   R   t   candst   infosR   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   from_requirementL   s    c         C   s   d „  |  j  Dƒ S(   Nc         s   s   |  ] } | j  Vq d  S(   N(   R   (   R   t   i(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys	   <genexpr>W   s    (   R   (   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR   V   s    c         C   s   d „  |  j  Dƒ S(   Nc         s   s   |  ] } | j  Vq d  S(   N(   R   (   R   R%   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys	   <genexpr>Z   s    (   R   (   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   iter_parentY   s    c   	      C   s   t  |  j ƒ } | j t | | ƒ ƒ t | j g  | D] \ } } | ^ q5 ƒ ƒ } t |  ƒ | | t  |  j ƒ ƒ } | s‰ t | ƒ ‚ n  | S(   s5   Build a new instance from this and a new requirement.(	   t   listR   t   appendR   R   R   t   typeR   R
   (	   R   R!   R   R   R#   R   t   _R"   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   merged_with\   s    .!c         C   sH   |  j  j | ƒ } | s d S|  j | } t |  ƒ | t |  j ƒ | ƒ S(   s   Build a new instance from this, but excluding specified candidates.

        Returns the new instance, or None if we still have no valid candidates.
        N(   R   t	   excludingt   NoneR   R)   R'   R   (   R   R   R"   t	   incompats(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   excluded_off   s
    (   R   R   R	   R   R   t   classmethodR$   R   R&   R+   R/   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR   ,   s   		
			
t   ResolutionErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR1   r   s   t   ResolutionImpossiblec           B   s   e  Z d  „  Z RS(   c         C   s#   t  t |  ƒ j | ƒ | |  _ d  S(   N(   R   R2   R   t   causes(   R   R3   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR   w   s    (   R   R   R   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR2   v   s   t   ResolutionTooDeepc           B   s   e  Z d  „  Z RS(   c         C   s#   t  t |  ƒ j | ƒ | |  _ d  S(   N(   R   R4   R   t   round_count(   R   R5   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR   ~   s    (   R   R   R   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR4   }   s   t   States   mapping criteriat
   Resolutionc           B   sn   e  Z d  Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z RS(   s­   Stateful 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         C   s   | |  _  | |  _ g  |  _ d  S(   N(   t   _pt   _rt   _states(   R   R!   t   reporter(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR   Ž   s    		c         C   s3   y |  j  d SWn t k
 r. t d ƒ ‚ n Xd  S(   Niÿÿÿÿt   state(   R:   t
   IndexErrort   AttributeError(   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR<   “   s    c         C   sH   |  j  d } t d | j j ƒ  d | j j ƒ  ƒ } |  j  j | ƒ d S(   s‰   Push a new state into history.

        This new state will be used to hold resolution results of the next
        coming round.
        iÿÿÿÿt   mappingt   criteriaN(   R:   R6   R?   t   copyR@   R(   (   R   t   baseR<   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _push_new_stateš   s
    c         C   s‡   |  j  j | | ƒ |  j j | ƒ } y |  j j | } Wn) t k
 rd t j |  j | | ƒ } n X| j	 |  j | | ƒ } | | f S(   N(
   R9   t   adding_requirementR8   t   identifyR<   R@   t   KeyErrorR   R$   R+   (   R   R   R   t   namet   crit(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _merge_into_criterion§   s    c         C   s=   | \ } } |  j  j |  j j j | ƒ | j j ƒ  | j ƒ S(   N(   R8   t   get_preferenceR<   R?   t   getR   t   for_preferenceR   (   R   t   itemRG   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _get_criterion_item_preference²   s
    	c            sL   y ˆ j  j | ‰  Wn t k
 r( t SXt ‡  ‡ f d †  | j ƒ  Dƒ ƒ S(   Nc         3   s$   |  ] } ˆ j  j | ˆ  ƒ Vq d  S(   N(   R8   t   is_satisfied_by(   R   R   (   t   current_pinR   (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys	   <genexpr>À   s   (   R<   R?   RF   t   Falset   allR   (   R   RG   R   (    (   RP   R   s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _is_current_pin_satisfyingº   s    c         C   sL   i  } x? |  j  j | ƒ D]+ } |  j | d | ƒ\ } } | | | <q W| S(   NR   (   R8   t   get_dependenciesRI   (   R   R   R@   R   RG   RH   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _get_criteria_to_updateÄ   s
    c            sá   g  } xÔ | j  D]É ‰  y ˆ j ˆ  ƒ } Wn& t k
 rQ } | j | j ƒ q n Xt ‡  ‡ f d †  | j ƒ  Dƒ ƒ } | s t ˆ  | ƒ ‚ n  ˆ j j	 ˆ  ƒ ˆ j
 j j | d  ƒ ˆ  ˆ j
 j | <ˆ j
 j j | ƒ g  SW| S(   Nc         3   s$   |  ] } ˆ j  j | ˆ  ƒ Vq d  S(   N(   R8   RO   (   R   R   (   R   R   (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys	   <genexpr>Ù   s   (   R   RU   R
   R(   R   RR   R   R   R9   t   pinningR<   R?   t   popR-   R@   t   update(   R   RG   R   R3   R@   t   et	   satisfied(    (   R   R   s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _attempt_to_pin_criterionË   s$    c            sÔ   xÍ t  ˆ j ƒ d k rÏ ˆ j d =ˆ j j ƒ  } | j j ƒ  \ } } g  | j j ƒ  D] \ } } | | j f ^ qV ‰  ˆ  j | | g f ƒ ˆ j	 j
 | ƒ ‡  ‡ f d †  } ˆ j ƒ  | ƒ  } | r t Sq Wt S(   sè  Perform backtracking.

        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.  Discard Z.
        2.  Discard Y but remember its incompatibility information gathered
            previously, and the failure we're dealing with right now.
        3.  Push a new state Y' based on X, and apply the incompatibility
            information from Y to Y'.
        4a. If this causes Y' to conflict, we need to backtrack again. Make Y'
            the new Z and go back to step 2.
        4b. If the incompatibilities apply cleanly, end backtracking.
        i   iÿÿÿÿc             s   xz ˆ  D]r \ }  } | s q n  y ˆ j  j |  } Wn t k
 rI q n X| j | ƒ } | d  k ri t S| ˆ j  j |  <q Wt S(   N(   R<   R@   RF   R/   R-   RQ   t   True(   t   kR   R   (   t   incompatibilities_from_brokenR   (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _patch_criteria  s    (   t   lenR:   RW   R?   t   popitemR@   t   itemsR   R(   R9   t   backtrackingRC   R\   RQ   (   R   t   broken_stateRG   R   R]   t   vR_   t   success(    (   R^   R   s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt
   _backtrackì   s    
.
	c         C   sã  |  j  r t d ƒ ‚ n  |  j j ƒ  t d t j ƒ  d i  ƒ g |  _  xe | D]] } y |  j | d d  ƒ\ } } Wn% t	 k
 r™ } t
 | j j ƒ ‚ n X| |  j j | <qM W|  j ƒ  xt | ƒ D]
} |  j j | ƒ g  |  j j j ƒ  D] } |  j | Œ  sî | ^ qî }	 |	 s/|  j j |  j ƒ |  j St |	 d |  j ƒ\ } }
 |  j | |
 ƒ } | r¯|  j ƒ  } | s¹g  | D] } | j D] } | ^ qˆq{} t
 | ƒ ‚ q¹n
 |  j ƒ  |  j j | |  j ƒ qÅ Wt | ƒ ‚ d  S(   Ns   already resolvedR?   R@   R   t   key(   R:   t   RuntimeErrorR9   t   startingR6   t   collectionst   OrderedDictRI   R-   R
   R2   R   R   R<   R@   RC   t   ranget   starting_roundRb   RS   t   endingt   minRN   R[   Rg   t   ending_roundR4   (   R   R   t
   max_roundsR   RG   RH   RY   t   round_indexRM   t   unsatisfied_criterion_itemsR   t   failure_causesRf   t   cR%   R3   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   resolve4  s>    	!
)
(   R   R   R	   R   t   propertyR<   RC   RI   RN   RS   RU   R[   Rg   Rw   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR7   ‡   s   					
		!	Hc         C   s­   | | k r t  S| |  k r  t Sx† |  | j ƒ  D]t } y | t | ƒ } Wn t k
 ra q1 n X| | k r | j | ƒ t  St |  | | | ƒ r1 | j | ƒ t  Sq1 Wt S(   N(   R\   RQ   R&   t   idRF   t   addt   _has_route_to_root(   R@   Rh   t   all_keyst	   connectedt   pt   pkey(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR{   o  s     t   Results   mapping graph criteriac            sH  |  j  } d „  | j ƒ  Dƒ } d  | t d  ƒ <t ƒ  } | j d  ƒ d  h ‰  xÅ |  j j ƒ  D]´ \ } } t |  j | | ˆ  ƒ sˆ q^ n  | | k r¤ | j | ƒ n  xk | j ƒ  D]] } y | t | ƒ } Wn t	 k
 rá q± n X| | k rþ | j | ƒ n  | j
 | | ƒ q± Wq^ Wt d ‡  f d †  | j ƒ  Dƒ d | d |  j ƒ S(   Nc         S   s%   i  |  ] \ } } | t  | ƒ “ q S(    (   Ry   (   R   R]   Re   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys
   <dictcomp>‡  s   	 R?   c            s+   i  |  ]! \ } } | ˆ  k r | | “ q S(    (    (   R   R]   Re   (   R}   (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pys
   <dictcomp>  s   	 t   graphR@   (   R?   Rb   R-   Ry   R   Rz   R@   R{   R&   RF   t   connectR€   (   R<   R?   R|   R   Rh   R   R~   R   (    (   R}   s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   _build_result…  s.    			t   Resolverc           B   s    e  Z d  Z e Z d d „ Z RS(   s3   The thing that performs the actual resolution work.id   c         C   s4   t  |  j |  j ƒ } | j | d | ƒ} t | ƒ S(   s  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.
        Rr   (   R7   R!   R;   Rw   Rƒ   (   R   R   Rr   t
   resolutionR<   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyRw   ¨  s    (   R   R   R	   R   t   base_exceptionRw   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyR„   £  s   (   Rk   t	   providersR    t   structsR   R   t
   namedtupleR   t	   ExceptionR   R
   R   t   objectR   R1   R2   R4   R6   R7   R{   R€   Rƒ   R„   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/resolvers.pyt   <module>   s"   Fè		