ó
Ð²Ebc           @   s  d  d l  Z  d  d l m Z d  d l m Z m Z m Z m Z m Z m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z m Z m Z d  d	 l m Z d  d
 l m Z d d l m Z d d l m Z m Z m Z m  Z  m! Z! d d l" m# Z# d d l$ m% Z% m& Z& m' Z' m( Z( e rgd  d l) m* Z* m+ Z+ m, Z, m- Z- m. Z. m/ Z/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 d  d l4 m5 Z5 d  d l6 m7 Z7 d  d l8 m9 Z9 d  d l: m; Z; d  d l< m= Z= m> Z> d  d l? m@ Z@ d  d lA mB ZB d  d lC mD ZD d  d lE mF ZF d d l mG ZG mH ZH d d l mI ZI e3 d ƒ ZJ e* eB eJ f ZK e* e7 eG f ZL n  e  jM eN ƒ ZO d eP f d „  ƒ  YZQ d S(   iÿÿÿÿN(   t   canonicalize_name(   t   DistributionNotFoundt   InstallationErrort   InstallationSubprocessErrort   MetadataInconsistentt   UnsupportedPythonVersiont   UnsupportedWheel(   t   Wheel(   t   InstallRequirement(   t   get_supported(   t   Hashes(   t   dist_in_site_packagest   dist_in_usersitet   get_installed_distributions(   t   MYPY_CHECK_RUNNING(   t   running_under_virtualenvi   (   t
   Constraint(   t   AlreadyInstalledCandidatet   EditableCandidatet   ExtrasCandidatet   LinkCandidatet   RequiresPythonCandidate(   t   FoundCandidates(   t   ExplicitRequirementt   RequiresPythonRequirementt   SpecifierRequirementt   UnsatisfiableRequirement(
   t   Dictt	   FrozenSett   Iterablet   Iteratort   Listt   Optionalt   Sequencet   Sett   Tuplet   TypeVar(   t   SpecifierSet(   t   _BaseVersion(   t   Distribution(   t   ResolutionImpossible(   t
   CacheEntryt
   WheelCache(   t   PackageFinder(   t   Link(   t   RequirementPreparer(   t   InstallRequirementProvider(   t	   Candidatet   Requirement(   t   BaseCandidatet   Ct   Factoryc           B   s’   e  Z d d  „ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z RS(   c
   
      C   s¤   | |  _  | |  _ | |  _ t |	 ƒ |  _ | |  _ | |  _ | |  _ | |  _ i  |  _	 i  |  _
 i  |  _ i  |  _ | s— d „  t d t ƒ Dƒ |  _ n	 i  |  _ d  S(   Nc         S   s"   i  |  ] } | t  | j ƒ “ q S(    (   R    t   project_name(   t   .0t   dist(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pys
   <dictcomp>l   s   	t
   local_only(   t   _findert   preparert   _wheel_cacheR   t   _python_candidatet   _make_install_req_from_spect   _use_user_sitet   _force_reinstallt   _ignore_requires_pythont   _build_failurest   _link_candidate_cachet   _editable_candidate_cachet   _installed_candidate_cacheR   t   Falset   _installed_dists(
   t   selft   finderR9   t   make_install_reqt   wheel_cachet   use_user_sitet   force_reinstallt   ignore_installedt   ignore_requires_pythont   py_version_info(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   __init__N   s     											c         C   s   |  j  S(   N(   R>   (   RF   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyRK   r   s    c         C   sd   y |  j  | j } Wn6 t k
 rL t | | d |  ƒ} | |  j  | j <n X| r` t | | ƒ S| S(   Nt   factory(   RC   t   keyt   KeyErrorR   R   (   RF   R6   t   extrast   templatet   base(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   _make_candidate_from_distw   s    c      	   C   sF  | |  j  k r d  S| j r§ | |  j k r— y, t | | d |  d | d | ƒ|  j | <Wq— t t f k
 r“ } t j d | | ƒ | |  j  | <d  SXn  |  j | } nˆ | |  j	 k r"y, t
 | | d |  d | d | ƒ|  j	 | <Wq"t t f k
 r} t j d | | ƒ | |  j  | <d  SXn  |  j	 | } | rBt | | ƒ S| S(   NRP   t   namet   versions   Discarding %s. %s(   R@   t   Nonet   editableRB   R   R   R   t   loggert   warningRA   R   R   (   RF   t   linkRS   RT   RW   RX   t   eRU   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   _make_candidate_from_link‡   s4    	c   	         s  | s
 d S| d ‰ t  ˆ j j ƒ ‰ t ƒ  ‰  xG | D]? } ˆ | j j M‰ ˆ | j d t ƒ M‰ ˆ  t | j ƒ O‰  q6 Wd  } ˆ j	 rá ˆ ˆ j
 k rá ˆ j
 ˆ } ˆ j | j d t ƒrá ˆ j d | d ˆ  d ˆ ƒ } qá n  ‡  ‡ ‡ ‡ ‡ ‡ f d †  } t | | | ƒ S(	   Ni    t   trust_internett   prereleasesR6   RS   RT   c          3   sò   ˆ j  j d ˆ d ˆ d ˆ ƒ }  t |  j ƒ  ƒ } t d „  | Dƒ ƒ } t ƒ  } x™ t | ƒ D]‹ } | r~ | j j r~ q_ n  | j	 | k r“ q_ n  ˆ j
 d | j d ˆ  d ˆ d ˆ d	 | j	 ƒ } | d  k rÕ q_ n  | V| j | j	 ƒ q_ Wd  S(
   NR4   t	   specifiert   hashesc         s   s   |  ] } | j  j Vq d  S(   N(   R]   t	   is_yanked(   R5   t   ican(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pys	   <genexpr>æ   s    R]   RS   RT   RW   RX   (   R8   t   find_best_candidatet   listt   iter_applicablet   allt   sett   reversedR]   Rd   RX   R_   RY   t   add(   t   resultt   icanst
   all_yankedt   versions_foundRe   t	   candidate(   RS   Rc   RW   RF   Rb   RT   (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   iter_index_candidatesÚ   s,    				(    (   R    t   reqRW   t	   frozensetRb   Rc   RD   RS   RY   R>   RE   t   containsRX   t   TrueRV   R   (	   RF   t   ireqsRb   Rc   t   prefers_installedt   ireqt   installed_candidatet   installed_distRr   (    (   RS   Rc   RW   RF   Rb   RT   sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   _iter_found_candidatesµ   s,    
		!c   	         s£   t  ƒ  } g  } xX ˆ D]P } | j ƒ  \ } } | d  k	 rJ | j | ƒ n  | d  k	 r | j | ƒ q q W| sŒ |  j | ˆ  j ˆ  j | ƒ S‡  ‡ f d †  | Dƒ S(   Nc         3   s@   |  ]6 ‰  ˆ j  ˆ  ƒ r t ‡  f d  †  ˆ Dƒ ƒ r ˆ  Vq d S(   c         3   s   |  ] } | j  ˆ  ƒ Vq d  S(   N(   t   is_satisfied_by(   R5   Rs   (   t   c(    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pys	   <genexpr>  s    N(   R}   Ri   (   R5   (   t
   constraintt   requirements(   R~   sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pys	   <genexpr>  s    (   Rj   t   get_candidate_lookupRY   Rl   t   appendR|   Rb   Rc   (	   RF   R€   R   Rx   t   explicit_candidatesRw   Rs   t   candRy   (    (   R   R€   sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   find_candidates  s    	c      
   C   s/  | j  | ƒ s, t j d | j | j ƒ d  S| j s? t | ƒ S| j j rœ t	 | j j
 ƒ } | j |  j j j ƒ  ƒ sœ d j | j
 ƒ } t | ƒ ‚ qœ n  |  j | j d t | j ƒ d | d | j rØ t | j ƒ n d  d d  ƒ} | d  k r"| j s|  j | j ‚ n  t t | j ƒ ƒ S|  j | ƒ S(   Ns6   Ignoring %s: markers '%s' don't match your environments-   {} is not a supported wheel on this platform.RS   RT   RW   RX   (   t   match_markersR[   t   infoRW   t   markersRY   R]   R   t   is_wheelR   t   filenamet	   supportedR8   t   target_pythont   get_tagst   formatR   R_   Rt   RS   R    R@   R   t   make_requirement_from_candidate(   RF   Ry   t   requested_extrast   wheelt   msgR„   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt!   make_requirement_from_install_req!  s0    	
			c         C   s
   t  | ƒ S(   N(   R   (   RF   Rq   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyR   E  s    c         C   s"   |  j  | | ƒ } |  j | | ƒ S(   N(   R<   R“   (   RF   Rb   t
   comes_fromR   Ry   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   make_requirement_from_specI  s    c         C   s)   |  j  s | d  k r d  St | |  j ƒ S(   N(   R?   RY   R   R;   (   RF   Rb   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt    make_requires_python_requirementS  s    c         C   sA   |  j  d k s |  j j r d S|  j  j d | d | d t ƒ  ƒ S(   s—  Look up the link in the wheel cache.

        If ``preparer.require_hashes`` is True, don't use the wheel cache,
        because cached wheels, always built locally, have different hashes
        than the files downloaded from the index server and thus throw false
        hash mismatches. Furthermore, cached wheels at present have
        nondeterministic contents due to file modification times.
        R]   t   package_namet   supported_tagsN(   R:   RY   R9   t   require_hashest   get_cache_entryR	   (   RF   R]   RW   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   get_wheel_cache_entryY  s    
c         C   s|   |  j  j | j ƒ } | d  k r% d  S|  j s2 | St | ƒ rB | St ƒ  rx t | ƒ rx t d j	 | j
 | j ƒ ƒ ‚ n  d  S(   NsV   Will not install to the user site because it will lack sys.path precedence to {} in {}(   RE   t   getRW   RY   R=   R   R   R   R   RŽ   R4   t   location(   RF   Rq   R6   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   get_dist_to_uninstallk  s    	c         C   s@   d } | j  d | j d |  j j d t | j ƒ ƒ } t | ƒ S(   NsO   Package {package!r} requires a different Python: {version} not in {specifier!r}t   packageRX   Rb   (   RŽ   RW   R;   RX   t   strRb   R   (   RF   t   requirementRT   t   message_formatt   message(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   _report_requires_python_error‰  s    		c         C   s  | j  s t d ƒ ‚ x9 | j  D]. } t | j t ƒ r |  j | j | j ƒ Sq Wt | j  ƒ d k rÌ | j  d \ } } | d  k r” t	 | ƒ } n d j
 | | j ƒ } t j d | ƒ t d j
 | ƒ ƒ Sd „  } d „  } t ƒ  } xK | j  D]@ \ } } | d  k r| j ƒ  }	 n | | ƒ }	 | j |	 ƒ qñ W| rP| t | ƒ ƒ }
 n d	 }
 d
 j
 |
 ƒ } t j | ƒ d } x` | j  D]U \ } } | d } | r½| d j
 | j | j ƒ } n
 | d } | | j ƒ  } q‚W| d d d d d } t j | ƒ t d ƒ S(   Ns)   Installation error reported with no causei   i    s   {} (from {})s:   Could not find a version that satisfies the requirement %ss%   No matching distribution found for {}c         S   s7   t  |  ƒ d k r |  d Sd j |  d  ƒ d |  d S(   Ni   i    s   , iÿÿÿÿs    and (   t   lent   join(   t   parts(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt	   text_join¿  s    c         S   sb   |  j  ƒ  } | s | j r3 d j |  j |  j ƒ St | j t ƒ rU t | j j ƒ St | j ƒ S(   Ns   {}=={}(   t   get_install_requirementR”   RŽ   RW   RX   t
   isinstanceR   R    (   t   parentRy   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   describe_triggerÆ  s    s   the requested packagessO   Cannot install {} because these package versions have conflicting dependencies.s   
The conflict is caused by:s   
    s   {} {} depends on s   The user requested s   

s   To fix this you could try to:
s9   1. loosen the range of package versions you've specified
s9   2. remove package versions to allow pip attempt to solve s   the dependency conflict
sn   ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies(   t   causest   AssertionErrorRª   R¡   R   R¤   R«   R¥   RY   R    RŽ   RW   R[   t   criticalR   Rj   t   format_for_errorRl   t   sortedRX   R‡   (   RF   R^   t   causeRs   R«   t   req_dispR¨   R¬   t   triggerst   triggerR‡   R’   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   get_installation_errorš  sX    					
	
N(    (   t   __name__t
   __module__RY   RO   t   propertyRK   RV   R_   R|   R…   R“   R   R•   R–   R›   Rž   R¤   R¶   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyR3   M   s   		.	L	 	$					(R   t   loggingt   pip._vendor.packaging.utilsR    t   pip._internal.exceptionsR   R   R   R   R   R   t   pip._internal.models.wheelR   t   pip._internal.req.req_installR   t&   pip._internal.utils.compatibility_tagsR	   t   pip._internal.utils.hashesR
   t   pip._internal.utils.miscR   R   R   t   pip._internal.utils.typingR   t   pip._internal.utils.virtualenvR   RU   R   t
   candidatesR   R   R   R   R   t   found_candidatesR   R€   R   R   R   R   t   typingR   R   R   R   R   R    R!   R"   R#   R$   t    pip._vendor.packaging.specifiersR%   t   pip._vendor.packaging.versionR&   t   pip._vendor.pkg_resourcesR'   t   pip._vendor.resolvelibR(   t   pip._internal.cacheR)   R*   t"   pip._internal.index.package_finderR+   t   pip._internal.models.linkR,   t    pip._internal.operations.prepareR-   t   pip._internal.resolution.baseR.   R/   R0   R1   R2   t   Cachet   VersionCandidatest	   getLoggerR·   R[   t   objectR3   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_internal/resolution/resolvelib/factory.pyt   <module>   s>   .("F