3
g#                 @   s   d dl Z d dlZd dlmZmZmZmZmZmZ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 erd dl
mZ d d	lmZ eeef Zeeeef ZneZG d
d deZdS )    N)TYPE_CHECKINGDictIterableIteratorMappingSequenceUnion)AbstractProvider   )	Candidate
ConstraintRequirement)REQUIRES_PYTHON_IDENTIFIER)Factory)
Preference)RequirementInformationc               @   s  e Zd ZdZeeeef eeeee	f ddddZ
eeef edddZeeeef eeee f eeed	 f ed	 d
dddZeedddZeeeee f eeee f ee dddZeeedddZeee dddZeeed	 edddZdS )PipProvidera  Pip's provider implementation for resolvelib.

    :params constraints: A mapping of constraints specified by the user. Keys
        are canonicalized project names.
    :params ignore_dependencies: Whether the user specified ``--no-deps``.
    :params upgrade_strategy: The user-specified upgrade strategy.
    :params user_requested: A set of canonicalized package names that the user
        supplied for pip to install/upgrade.
    N)factoryconstraintsignore_dependenciesupgrade_strategyuser_requestedreturnc             C   s2   || _ || _|| _|| _|| _tjdd | _d S )Nc               S   s   t jS )N)mathinf r   r   j/var/www/tester-filtro-web/env/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/provider.py<lambda>@   s    z&PipProvider.__init__.<locals>.<lambda>)_factory_constraints_ignore_dependencies_upgrade_strategy_user_requestedcollectionsdefaultdict_known_depths)selfr   r   r   r   r   r   r   r   __init__3   s    zPipProvider.__init__)requirement_or_candidater   c             C   s   |j S )N)name)r&   r(   r   r   r   identifyB   s    zPipProvider.identifyPreferenceInformationr   )
identifierresolutions
candidatesinformationbacktrack_causesr   c                s  dd || D }t | \}}dd dd |D D }	|dk	}
tdd |	D }t|	}y j| }W nF tk
r   tj} fdd|| D }td	d |D d
 }Y nX d
}| j|<  jj	|tj}|t
k}|dk} j||}| ||
 | | ||| |f	S )a[  Produce a sort key for given requirement based on preference.

        The lower the return value is, the more preferred this group of
        arguments is.

        Currently pip considers the followings in order:

        * Prefer if any of the known requirements is "direct", e.g. points to an
          explicit URL.
        * If equal, prefer if any requirement is "pinned", i.e. contains
          operator ``===`` or ``==``.
        * If equal, calculate an approximate "depth" and resolve requirements
          closer to the user-specified requirements first.
        * Order user-specified requirements by the order they are specified.
        * If equal, prefers "non-free" requirements, i.e. contains at least one
          operator, such as ``>=`` or ``<``.
        * If equal, order alphabetically for consistency (helps debuggability).
        c             s   s   | ]\}}|j  V  qd S )N)Zget_candidate_lookup).0r_r   r   r   	<genexpr>_   s    z-PipProvider.get_preference.<locals>.<genexpr>c             S   s   g | ]}|D ]
}|j qqS r   )operator)r1   Zspecifier_set	specifierr   r   r   
<listcomp>b   s   z.PipProvider.get_preference.<locals>.<listcomp>c             s   s   | ]}|r|j V  qd S )N)r6   )r1   ireqr   r   r   r4   c   s    Nc             s   s   | ]}|d d dkV  qd S )N   z==r   )r1   opr   r   r   r4   h   s    c             3   s*   | ]"\}}|d k	r j |j ndV  qd S )Ng        )r%   r)   )r1   r3   parent)r&   r   r   r4   p   s   c             s   s   | ]
}|V  qd S )Nr   )r1   dr   r   r   r4   s   s    g      ?
setuptools)zipanyboolr"   KeyErrorr   r   minr%   getr   is_backtrack_cause)r&   r,   r-   r.   r/   r0   Zlookups	candidateZireqs	operatorsdirectZpinnedZunfreeZrequested_orderZparent_depthsZinferred_depthrequires_pythonZ
delay_thisbacktrack_causer   )r&   r   get_preferenceE   s:    


zPipProvider.get_preference)r,   r   c             C   sD   || j kr| j | S |jd\}}}|r<|| j kr<| j | S tj S )N[)r   	partitionr   empty)r&   r,   r)   Zopen_bracketr3   r   r   r   _get_constraint   s    


zPipProvider._get_constraint)r,   requirementsincompatibilitiesr   c                s6   t td fdd} jj|| j||| |dS )N)r)   r   c                s&    j dkrdS  j dkr"|  jkS d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).
            eagerTzonly-if-neededF)r!   r"   )r)   )r&   r   r   _eligible_for_upgrade   s
    


z7PipProvider.find_matches.<locals>._eligible_for_upgrade)r,   rO   
constraintZprefers_installedrP   )strr@   r   Zfind_candidatesrN   )r&   r,   rO   rP   rR   r   )r&   r   find_matches   s    zPipProvider.find_matches)requirementrE   r   c             C   s
   |j |S )N)is_satisfied_by)r&   rV   rE   r   r   r   rW      s    zPipProvider.is_satisfied_by)rE   r   c             C   s   | j  }dd |j|D S )Nc             S   s   g | ]}|d k	r|qS )Nr   )r1   r2   r   r   r   r7      s    z0PipProvider.get_dependencies.<locals>.<listcomp>)r    iter_dependencies)r&   rE   Zwith_requiresr   r   r   get_dependencies   s    zPipProvider.get_dependencies)r,   r0   r   c             C   s8   x2|D ]*}| |j jkrdS |jr| |jjkrdS qW dS )NTF)rV   r)   r;   )r,   r0   rI   r   r   r   rD      s    
zPipProvider.is_backtrack_cause)__name__
__module____qualname____doc__r   r   rT   r   r@   intr'   r   r   r   r*   r   r   r   r   rJ   rN   rU   rW   rY   staticmethodrD   r   r   r   r   r   (   s0   	


Mr   )r#   r   typingr   r   r   r   r   r   r   Z pip._vendor.resolvelib.providersr	   baser   r   r   r.   r   r   r   r    pip._vendor.resolvelib.resolversr   r+   rT   Z_ProviderBaser   r   r   r   r   <module>   s   $