ó
'—^c           @   sí  d  Z  d d l 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 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 m Z d d l  m! Z! e! r•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/ d d l0 m1 Z1 n  e j2 e3 ƒ Z4 d e f d „  ƒ  YZ5 d e e5 f d „  ƒ  YZ6 d e6 f d „  ƒ  YZ7 d S(   s  Contains the Command base classes that depend on PipSession.

The classes in this module are in a separate module so the commands not
needing download / PackageFinder capability don't unnecessarily import the
PackageFinder machinery and all its vendored dependencies, etc.
iÿÿÿÿN(   t   partial(   t   Command(   t   CommandContextMixIn(   t   CommandError(   t   PackageFinder(   t   Resolver(   t   SelectionPreferences(   t
   Downloader(   t
   PipSession(   t   RequirementPreparer(   t   install_req_from_editablet   install_req_from_linet   install_req_from_req_string(   t   parse_requirements(   t   make_link_collectort   pip_self_version_check(   t   MYPY_CHECK_RUNNING(   t   Values(   t   Listt   Optionalt   Tuple(   t
   WheelCache(   t   TargetPython(   t   RequirementSet(   t   RequirementTracker(   t   TempDirectoryt   SessionCommandMixinc           B   s>   e  Z d  Z d „  Z e d „  ƒ Z d „  Z d d d „ Z RS(   sE   
    A class mixin for command classes needing _build_session().
    c         C   s    t  t |  ƒ j ƒ  d  |  _ d  S(   N(   t   superR   t   __init__t   Nonet   _session(   t   self(    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyR   2   s    c         C   su   g  } t  | d t ƒ sC t  | d d ƒ } | rC | j | ƒ qC n  t  | d d ƒ } | rk | j | ƒ n  | pt d S(   s7   Return a list of index urls from user-provided options.t   no_indext	   index_urlt   extra_index_urlsN(   t   getattrt   FalseR   t   appendt   extend(   t   clst   optionst
   index_urlst   urlt   urls(    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   _get_index_urls7   s    c         C   sI   |  j  d k rB |  j |  j | ƒ ƒ |  _  |  j  d k	 sB t ‚ n  |  j  S(   s   Get a default-managed session.N(   R   R   t   enter_contextt   _build_sessiont   AssertionError(   R   R(   (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   get_default_sessionF   s    c      
   C   s%  | j  s% t j j | j  ƒ s% t ‚ t d | j  rL t j j | j  d ƒ n d  d | d  k	 rd | n | j d | j	 d |  j
 | ƒ ƒ } | j r  | j | _ n  | j r¸ | j | _ n  | j sÇ | rè | d  k	 rÙ | n | j | _ n  | j ri | j d 6| j d 6| _ n  | j | j _ | S(   Nt   cachet   httpt   retriest   trusted_hostsR)   t   https(   t	   cache_dirt   ost   patht   isabsR/   R   t   joinR   R3   R4   R,   t   certt   verifyt   client_certt   timeoutt   proxyt   proxiest   no_inputt   autht	   prompting(   R   R(   R3   R>   t   session(    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyR.   Q   s$    %'			!	
N(	   t   __name__t
   __module__t   __doc__R   t   classmethodR,   R0   R   R.   (    (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyR   -   s
   		t   IndexGroupCommandc           B   s   e  Z d  Z d „  Z RS(   s–   
    Abstract base class for commands with the index_group options.

    This also corresponds to the commands that permit the pip version check.
    c         C   sp   t  | d ƒ s t ‚ | j s' | j r+ d S|  j | d d d t d | j ƒ ƒ} |  t | | ƒ Wd QXd S(   s€   
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        R    NR3   i    R>   i   (   t   hasattrR/   t   disable_pip_version_checkR    R.   t   minR>   R   (   R   R(   RD   (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   handle_pip_version_check   s    (   RE   RF   RG   RM   (    (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyRI   y   s   t   RequirementCommandc        
   B   sk   e  Z e d d d  „ ƒ Z e d e e e e d d d d „ ƒ Z d „  Z e d „  ƒ Z	 d d d „ Z
 RS(   c   
      C   s|   t  | d | j ƒ} |  j }	 |	 d k	 s0 t ‚ t d |	 d | j d | d | d | j d | d | d	 | d
 | j d | ƒ 
S(   sQ   
        Create a RequirementPreparer instance for the given parameters.
        t   progress_bart	   build_dirt   src_dirt   download_dirt   wheel_download_dirt   build_isolationt   req_trackert
   downloadert   findert   require_hashest   use_user_siteN(	   R   RO   R8   R   R/   R	   RQ   RT   RX   (
   t   temp_build_dirR(   RU   RD   RW   RY   RR   RS   RV   t   temp_build_dir_path(    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   make_requirement_preparerš   s    				s   to-satisfy-onlyc         C   sg   t  t d | j d | d |	 ƒ} t d |  d | d | d | d | j d	 | d
 | d | d | d |
 ƒ 
S(   sF   
        Create a Resolver instance for the given parameters.
        t   isolatedt   wheel_cachet
   use_pep517t   preparerRW   t   make_install_reqRY   t   ignore_dependenciest   ignore_installedt   ignore_requires_pythont   force_reinstallt   upgrade_strategyt   py_version_info(   R    R   t   isolated_modeR   Rb   (   R`   RW   R(   R^   RY   Rc   Rd   Re   Rf   R_   Rg   Ra   (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   make_resolver»   s     			c         C   s  x\ | j  D]Q } xH t | d t d | d | d | d | ƒD] } t | _ | j | ƒ q; Wq
 WxK | D]C }	 t |	 d d | j d | j d | ƒ} t | _ | j | ƒ qf WxK | j	 D]@ }	 t
 |	 d | j d | j d | ƒ} t | _ | j | ƒ q· Wx_ | j D]T } xK t | d | d | d | d | d | j ƒD] } t | _ | j | ƒ q9WqW| j t | j j ƒ  ƒ }
 t d „  |
 Dƒ ƒ r›t | _ n  | p°| j	 p°| j s
i |  j d	 6} | j r÷t d
 t | d d j | j ƒ ƒƒ ‚ q
t d | ƒ ‚ n  d S(   s?   
        Marshal cmd line args into a requirement set.
        t
   constraintRW   R(   RD   R^   R]   R_   c         s   s   |  ] } | j  Vq d  S(   N(   t   has_hash_options(   t   .0t   req(    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pys	   <genexpr>  s    t   names^   You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?)t   linkst    sL   You must give at least one requirement to %(name)s (see "pip help %(name)s")N(   t   constraintsR   t   Truet	   is_directt   add_requirementR   R   Rh   R_   t	   editablesR
   t   requirementst   unnamed_requirementst   listt   valuest   anyRX   Rn   t
   find_linksR   t   dictR:   (   R   t   requirement_sett   argsR(   RW   RD   R^   t   filenamet
   req_to_addRm   Rv   t   opts(    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   populate_requirement_setà   sV    										%c         C   s/   |  j  } | j ƒ  } | r+ t j | ƒ n  d S(   sE   
        Trace basic information about the provided objects.
        N(   t   search_scopet   get_formatted_locationst   loggert   info(   RW   Rƒ   t	   locations(    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   trace_basic_info&  s    	c         C   s^   t  | d | ƒ} t d t d | j d | j d | j d | ƒ } t j d | d | d	 | ƒ S(
   sÛ   
        Create a package finder appropriate to this requirement command.

        :param ignore_requires_python: Whether to ignore incompatible
            "Requires-Python" values in links. Defaults to False.
        R(   t   allow_yankedt   format_controlt   allow_all_prereleasest   prefer_binaryRd   t   link_collectort   selection_prefst   target_python(   R   R   Rr   RŠ   t   preRŒ   R   t   create(   R   R(   RD   R   Rd   R   RŽ   (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   _build_package_finder2  s    					N(   RE   RF   t   staticmethodR   R\   R$   Rr   Ri   R‚   Rˆ   R’   (    (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyRN   ˜   s    	F(8   RG   t   loggingR7   t	   functoolsR    t   pip._internal.cli.base_commandR   t!   pip._internal.cli.command_contextR   t   pip._internal.exceptionsR   t"   pip._internal.index.package_finderR   t   pip._internal.legacy_resolveR   t$   pip._internal.models.selection_prefsR   t   pip._internal.network.downloadR   t   pip._internal.network.sessionR   t    pip._internal.operations.prepareR	   t   pip._internal.req.constructorsR
   R   R   t   pip._internal.req.req_fileR   t!   pip._internal.self_outdated_checkR   R   t   pip._internal.utils.typingR   t   optparseR   t   typingR   R   R   t   pip._internal.cacheR   t"   pip._internal.models.target_pythonR   t   pip._internal.req.req_setR   t   pip._internal.req.req_trackerR   t   pip._internal.utils.temp_dirR   t	   getLoggerRE   R…   R   RI   RN   (    (    (    s:   /tmp/pip-build-eiI0Wo/pip/pip/_internal/cli/req_command.pyt   <module>   s8   L