
0c@_ö  ã               @   s°   d  d l  m Z d  d l m Z d  d l m Z e r– d  d l 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 Gd d	 „  d	 e ƒ Z d
 S)é    )ÚSpecifierSet)ÚAbstractProvider)ÚMYPY_CHECK_RUNNING)ÚAnyÚDictÚIterableÚOptionalÚSequenceÚSetÚTupleÚUnioné   )ÚRequirementÚ	Candidate)ÚFactoryc               @   sd   e  Z d  Z d d „  Z d d „  Z d d „  Z d d „  Z d	 d
 „  Z d d „  Z d d „  Z	 d S)ÚPipProviderc             C   s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S)N)Ú_factoryÚ_constraintsÚ_ignore_dependenciesÚ_upgrade_strategyÚuser_requested)ÚselfÚfactoryÚconstraintsÚignore_dependenciesZupgrade_strategyr   © r   úK/tmp/pip-build-jynh7p1z/pip/pip/_internal/resolution/resolvelib/provider.pyÚ__init__)   s
    					zPipProvider.__init__c                s4   ‡ f d d †  ‰  ‡  f d d †  } t  | d | ƒS)Nc                s3   ˆ  j  d k r d Sˆ  j  d k r/ |  ˆ  j k Sd S)aÔ  Are upgrades allowed for this project?

            This checks the upgrade strategy, and whether the project was one
            that the user specified in the command line, in order to decide
            whether we should upgrade if there's a newer version available.

            (Note that we don't need access to the `--upgrade` flag, because
            an upgrade strategy of "to-satisfy-only" means that `--upgrade`
            was not specified).
            ZeagerTzonly-if-neededF)r   r   )Úname)r   r   r   Ú_eligible_for_upgradeP   s
    z8PipProvider._sort_matches.<locals>._eligible_for_upgradec                s!   |  j  r ˆ  |  j ƒ r d Sd S)ay  Return a sort key for the matches.

            The highest priority should be given to installed candidates that
            are not eligible for upgrade. We use the integer value in the first
            part of the key to sort these before other candidates.

            We only pull the installed candidate to the bottom (i.e. most
            preferred), but otherwise keep the ordering returned by the
            requirement. The requirement is responsible for returning a list
            otherwise sorted for the resolver, taking account for versions
            and binary preferences as specified by the user.
            r   r   )Zis_installedr   )Úc)r   r   r   Úsort_keyb   s    z+PipProvider._sort_matches.<locals>.sort_keyÚkey)Úsorted)r   Úmatchesr!   r   )r   r   r   Ú_sort_matches8   s    zPipProvider._sort_matchesc             C   s   | j  S)N)r   )r   Ú
dependencyr   r   r   Úidentifyv   s    zPipProvider.identifyc             C   s
   t  | ƒ S)N)Úlen)r   Ú
resolutionÚ
candidatesZinformationr   r   r   Úget_preferencez   s    zPipProvider.get_preferencec             C   sQ   | s
 g  S|  j  j | d j t ƒ  ƒ } |  j j | | ƒ } t |  j | ƒ ƒ S)Nr   )r   Úgetr   r   r   Zfind_candidatesÚreversedr%   )r   ÚrequirementsÚ
constraintr*   r   r   r   Úfind_matches„   s    	zPipProvider.find_matchesc             C   s   | j  | ƒ S)N)Úis_satisfied_by)r   ÚrequirementÚ	candidater   r   r   r1   Ž   s    zPipProvider.is_satisfied_byc             C   s$   |  j  } d d „  | j | ƒ Dƒ S)Nc             S   s"   g  |  ] } | d  k	 r | ‘ q S)Nr   )Ú.0Úrr   r   r   ú
<listcomp>–   s   	z0PipProvider.get_dependencies.<locals>.<listcomp>)r   Ziter_dependencies)r   r3   Zwith_requiresr   r   r   Úget_dependencies’   s    
	zPipProvider.get_dependenciesN)
Ú__name__Ú
__module__Ú__qualname__r   r%   r'   r+   r0   r1   r7   r   r   r   r   r   (   s   >

r   N)Z pip._vendor.packaging.specifiersr   Z pip._vendor.resolvelib.providersr   Zpip._internal.utils.typingr   Ztypingr   r   r   r   r	   r
   r   r   Úbaser   r   r   r   r   r   r   r   r   Ú<module>   s   :