ó
b]c           @   s‚  d  Z  d d l 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 d d l m Z e j e ƒ Z e r9d d	 l m Z d d
 l m Z m Z m Z m Z m Z m Z m Z e e d f Z e e e f Z e e e e f Z e e e e f Z e e e e f Z  e e e  f Z! n  e d d d g ƒ Z" d „  Z# d d „ Z% d „  Z& d „  Z' d „  Z( d S(   s'   Validation of dependencies of packages
iÿÿÿÿN(   t
   namedtuple(   t   canonicalize_name(   t   RequirementParseError(   t)   make_distribution_for_install_requirement(   t   get_installed_distributions(   t   MYPY_CHECK_RUNNING(   t   InstallRequirement(   t   Anyt   Callablet   Dictt   Optionalt   Sett   Tuplet   Listt   PackageDetailst   versiont   requiresc          K   s®   |  i  k r# i t  d 6d d 6}  n  i  } t  } xr t |    D]d } t | j ƒ } y  t | j | j ƒ  ƒ | | <Wq< t k
 rŸ } t j	 d | | ƒ t
 } q< Xq< W| | f S(   s8   Converts a list of distributions into a PackageSet.
    t
   local_onlyt   skips%   Error parsing requirements for %s: %s(    (   t   FalseR   R   t   project_nameR   R   R   R   t   loggingt   warningt   True(   t   kwargst   package_sett   problemst   distt   namet   e(    (    s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyt!   create_package_set_from_installed$   s     c         C   sa  | d k r d „  } n  t ƒ  } t ƒ  } x*|  D]"} t ƒ  } t ƒ  } | | ƒ r[ q1 n  x· |  | j D]¨ } t | j ƒ } | |  k rÓ t }	 | j d k	 r± | j j ƒ  }	 n  |	 ri | j	 | | f ƒ qi qi n  |  | j
 }
 | j j |
 d t ƒsi | j	 | |
 | f ƒ qi qi W| r4t | d t ƒ| | <n  | r1 t | d t ƒ| | <q1 q1 W| | f S(   s—   Check if a package set is consistent

    If should_ignore is passed, it should be a callable that takes a
    package name and returns a boolean.
    c         S   s   t  S(   N(   R   (   R   (    (    s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyt   should_ignoreA   s    t   prereleasest   keyN(   t   Nonet   dictt   setR   R   R   R   t   markert   evaluatet   addR   t	   specifiert   containst   sortedt   str(   R   R   t   missingt   conflictingt   package_namet   missing_depst   conflicting_depst   reqR   t   missedR   (    (    s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyt   check_package_set9   s4    				c            sL   t  ƒ  \ } } t |  | ƒ } t | | ƒ ‰  | t | d ‡  f d †  ƒf S(   se   For checking if the dependency graph would be consistent after     installing given requirements
    R   c            s
   |  ˆ  k S(   N(    (   R   (   t	   whitelist(    s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyt   <lambda>x   t    (   R   t   _simulate_installation_oft   _create_whitelistR3   (   t
   to_installR   t   _t   would_be_installed(    (   R4   s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyt   check_install_conflictsh   s    c         C   sn   t  ƒ  } x^ |  D]V } t | ƒ } | j ƒ  } t | j ƒ } t | j | j ƒ  ƒ | | <| j | ƒ q W| S(   sB   Computes the version of packages after installing to_install.
    (	   R$   R   t   get_pkg_resources_distributionR   R!   R   R   R   R'   (   R9   R   t	   installedt   inst_reqt   abstract_distR   R   (    (    s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyR7   }   s    	c         C   sq   t  |  ƒ } x^ | D]V } | | k r+ q n  x; | | j D], } t | j ƒ | k r9 | j | ƒ Pq9 q9 Wq W| S(   N(   R$   R   R   R   R'   (   R;   R   t   packages_affectedR.   R1   (    (    s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyR8   ’   s    ()   t   __doc__R   t   collectionsR    t   pip._vendor.packaging.utilsR   t   pip._vendor.pkg_resourcesR   t   pip._internal.distributionsR   t   pip._internal.utils.miscR   t   pip._internal.utils.typingR   t	   getLoggert   __name__t   loggert   pip._internal.req.req_installR   t   typingR   R   R	   R
   R   R   R   R+   t
   PackageSett   Missingt   Conflictingt   MissingDictt   ConflictingDictt   CheckResultR   R   R"   R3   R<   R7   R8   (    (    (    s=   lib/python2.7/site-packages/pip/_internal/operations/check.pyt   <module>   s.   4	/		