ó
ä™L]c           @@ sk  d  Z  d d l m Z m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l m Z d d l m Z d d l m Z 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 m Z d d
 l  m! Z! d d l" m# Z# d d l$ m% Z% d d l& m' Z' m( Z( d d l) m* Z* d d l+ m, Z, d d l- m. Z. m/ Z/ d d l0 m1 Z1 m2 Z2 d d l3 m4 Z4 d d l5 m6 Z6 d d l7 m8 Z8 e6 r#d d l9 m: Z: m; Z; m< Z< m= Z= d d l m> Z> d d l? m@ Z@ d d lA mB ZB n  d g ZC e jD eE ƒ ZF d eG f d „  ƒ  YZH d eH f d „  ƒ  YZI d S(   s(   Base Command class, and related routinesi    (   t   absolute_importt   print_functionN(   t
   cmdoptions(   t   make_search_scope(   t   ConfigOptionParsert   UpdatingDefaultsHelpFormatter(   t   ERRORt   PREVIOUS_BUILD_DIR_ERRORt   SUCCESSt   UNKNOWN_ERRORt   VIRTUALENV_NOT_FOUND(   t
   PipSession(   t
   BadCommandt   CommandErrort   InstallationErrort   PreviousBuildDirErrort   UninstallationError(   t   PackageFinder(   t   SelectionPreferences(   t   TargetPython(   t   install_req_from_editablet   install_req_from_line(   t   parse_requirements(   t
   deprecated(   t   BrokenStdoutLoggingErrort   setup_logging(   t   get_progt   normalize_path(   t   pip_version_check(   t   MYPY_CHECK_RUNNING(   t   running_under_virtualenv(   t   Optionalt   Listt   Tuplet   Any(   t   Values(   t
   WheelCache(   t   RequirementSett   Commandc           B@ s_   e  Z d Z d Z e Z e d  „ Z d „  Z e	 d „  ƒ Z
 d d d „ Z d „  Z d „  Z RS(   c         C@ s¹   i |  j  d 6d t ƒ  |  j f d 6t ƒ  d 6t d 6|  j d 6|  j d 6| d 6} t | �  |  _ d	 |  j j ƒ  } t	 j
 |  j | ƒ |  _ t j t j |  j ƒ } |  j j | ƒ d  S(
   Nt   usages   %s %st   progt	   formattert   add_help_optiont   namet   descriptiont   isolateds
   %s Options(   R'   R   R+   R   t   Falset   __doc__R   t   parsert
   capitalizet   optparset   OptionGroupt   cmd_optsR   t   make_option_groupt   general_groupt   add_option_group(   t   selfR-   t	   parser_kwt   optgroup_namet   gen_opts(    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   __init__8   s    




c         C@ s
   t  ‚ d  S(   N(   t   NotImplementedError(   R8   t   optionst   args(    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   runQ   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   getattrR.   t   Nonet   appendt   extend(   t   clsR>   t
   index_urlst   urlt   urls(    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   _get_index_urlsU   s    c      
   C@ s  t  d | j r- t t j j | j d ƒ ƒ n d  d | d  k	 rE | 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   insecure_hostsRI   t   https(   R   t	   cache_dirR   t   ost   patht   joinRE   RO   t   trusted_hostsRL   t   certt   verifyt   client_certt   timeoutt   proxyt   proxiest   no_inputt   autht	   prompting(   R8   R>   RO   RZ   t   session(    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   _build_sessionc   s"    -			!	
c         C@ s   |  j  j | ƒ S(   N(   R0   t
   parse_args(   R8   R?   (    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyRb   ‰   s    c   	      C@ s  |  j  | ƒ \ } } | j | j |  _ t d |  j d | j d | j ƒ } t j d  d k r� d } t	 j
 ƒ  d k r„ d | } n  t | d	 d  d
 d  ƒn  | j r¶ d t j d <n  | j rÛ d j | j ƒ t j d <n  | j r|  j rt ƒ  st j d ƒ t j t ƒ qn  z€y) |  j | | ƒ } t | t ƒ rB| SWnPt k
 r} t j t | ƒ ƒ t j d d t ƒt  St! t" t# f k
 rÁ} t j t | ƒ ƒ t j d d t ƒt$ St% k
 r÷} t j d | ƒ t j d d t ƒt$ St& k
 r@t' d d t j( ƒ| t) j* k r<t+ j, d t j( ƒ n  t$ St- k
 rqt j d ƒ t j d d t ƒt$ St. k
 r•t j d d t ƒt/ SXWd  t0 | d ƒ o¹| j1 p¸| j2 } | r|  j3 | d d d t4 d | j5 ƒ ƒ} | � t6 | | ƒ Wd  QXn  t) j7 ƒ  Xt8 S(   Nt	   verbosityt   no_colort   user_log_filei   i   sÁ   A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-supportt   CPythonsŽ   Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. t   replacementt   gone_int   1t   PIP_NO_INPUTt    t   PIP_EXISTS_ACTIONs2   Could not find an activated virtualenv (required).s   Exception information:t   exc_infos   %ss    ERROR: Pipe to stdout was brokent   files   Operation cancelled by users
   Exception:RA   RO   i    RZ   i   (   i   i   (9   Rb   t   verboset   quietRc   R   Rd   t   logt   syst   version_infot   platformt   python_implementationR   RE   R]   RS   t   environt   exists_actionRU   t   require_venvt   ignore_require_venvR   t   loggert   criticalt   exitR
   R@   t
   isinstancet   intR   t   strt   debugt   TrueR   R   R   R   R   R   R   t   printt   stderrt   loggingt   DEBUGt	   tracebackt	   print_exct   KeyboardInterruptt   BaseExceptionR	   t   hasattrt   disable_pip_version_checkRA   Ra   t   minRZ   R   t   shutdownR   (	   R8   R?   R>   t   level_numbert   messaget   statust   exct   allow_version_checkR`   (    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   mainŽ   sz    		
			 	N(   t   __name__t
   __module__RE   R+   R'   R.   Ry   R<   R@   t   classmethodRL   Ra   Rb   R“   (    (    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyR&   3   s   	&	t   RequirementCommandc           B@ s&   e  Z e d  „  ƒ Z d d d „ Z RS(   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 |  _ | p~| j	 p~| j sÕi | 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
   constraintt   finderR>   R`   t   wheel_cacheR-   t
   use_pep517R+   s^   You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?)t   linksRk   sL   You must give at least one requirement to %(name)s (see "pip help %(name)s")N(   t   constraintsR   R�   t	   is_directt   add_requirementR   RE   t   isolated_modeR›   t	   editablesR   t   requirementst   require_hashest
   find_linksR   t   dictRU   (   t   requirement_setR?   R>   R™   R`   R+   Rš   t   filenamet
   req_to_addt   reqt   opts(    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   populate_requirement_setú   sP    										%c         C@ sg   t  | ƒ } t d t d | j d | j d | j d | ƒ } t j d | d | d | j 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.
        t   allow_yankedt   format_controlt   allow_all_prereleasest   prefer_binaryt   ignore_requires_pythont   search_scopet   selection_prefsRV   R`   t   target_python(	   R   R   R�   R­   t   preR¯   R   t   createRV   (   R8   R>   R`   R³   R°   R±   R²   (    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   _build_package_finder=  s    						N(   R”   R•   t   staticmethodR«   RE   R¶   (    (    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyR—   ø   s   G(J   R/   t
   __future__R    R   R„   t   logging.configR2   RS   Rt   Rr   R†   t   pip._internal.cliR   t   pip._internal.cli.cmdoptionsR   t   pip._internal.cli.parserR   R   t   pip._internal.cli.status_codesR   R   R   R	   R
   t   pip._internal.downloadR   t   pip._internal.exceptionsR   R   R   R   R   t   pip._internal.indexR   t$   pip._internal.models.selection_prefsR   t"   pip._internal.models.target_pythonR   t   pip._internal.req.constructorsR   R   t   pip._internal.req.req_fileR   t   pip._internal.utils.deprecationR   t   pip._internal.utils.loggingR   R   t   pip._internal.utils.miscR   R   t   pip._internal.utils.outdatedR   t   pip._internal.utils.typingR   t   pip._internal.utils.virtualenvR   t   typingR   R    R!   R"   R#   t   pip._internal.cacheR$   t   pip._internal.req.req_setR%   t   __all__t	   getLoggerR”   Rz   t   objectR&   R—   (    (    (    s;   /tmp/pip-build-sZz8gW/pip/pip/_internal/cli/base_command.pyt   <module>   sD   (("	Å