๓
jทร^c           @@ s๕  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 m Z m Z m Z m 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' d d l( m) Z) m* Z* d d l+ m, Z, d d l- m. Z. e, rรd d l/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 d d l m4 Z4 d d l( m5 Z6 n  d g Z7 e j8 e9  Z: d e f d     YZ; d S(   s(   Base Command class, and related routinesi    (   t   absolute_importt   print_functionN(   t
   cmdoptions(   t   CommandContextMixIn(   t   ConfigOptionParsert   UpdatingDefaultsHelpFormatter(   t   ERRORt   PREVIOUS_BUILD_DIR_ERRORt   SUCCESSt   UNKNOWN_ERRORt   VIRTUALENV_NOT_FOUND(   t
   BadCommandt   CommandErrort   InstallationErrort   PreviousBuildDirErrort   UninstallationError(   t
   deprecated(   t   check_path_owner(   t   BrokenStdoutLoggingErrort   setup_logging(   t   get_progt   normalize_path(   t   global_tempdir_managert   tempdir_registry(   t   MYPY_CHECK_RUNNING(   t   running_under_virtualenv(   t   Listt   Optionalt   Tuplet   Any(   t   Values(   t   TempDirectoryTypeRegistryt   Commandc           B@ sM   e  Z d Z e Z e d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   c         C@ s่   t  t |   j   i |  j d 6d j t   |  d 6t   d 6t d 6| d 6|  j d 6| d 6} | |  _	 | |  _
 t |   |  _ d  |  _ d	 j |  j	 j    } t j |  j |  |  _ t j t j |  j  } |  j j |  d  S(
   Nt   usages   {} {}t   progt	   formattert   add_help_optiont   namet   descriptiont   isolateds
   {} Options(   t   superR    t   __init__R!   t   formatR   R   t   Falset   __doc__R%   t   summaryR   t   parsert   NoneR   t
   capitalizet   optparset   OptionGroupt   cmd_optsR   t   make_option_groupt   general_groupt   add_option_group(   t   selfR%   R-   R'   t	   parser_kwt   optgroup_namet   gen_opts(    (    s/   site-packages/pip/_internal/cli/base_command.pyR)   =   s&    



			c         C@ s   t  | d  s t  d S(   sf   
        This is a no-op so that commands by default do not do the pip version
        check.
        t   no_indexN(   t   hasattrt   AssertionError(   R7   t   options(    (    s/   site-packages/pip/_internal/cli/base_command.pyt   handle_pip_version_check[   s    c         C@ s
   t   d  S(   N(   t   NotImplementedError(   R7   R>   t   args(    (    s/   site-packages/pip/_internal/cli/base_command.pyt   rune   s    c         C@ s   |  j  j |  S(   N(   R.   t
   parse_args(   R7   RA   (    (    s/   site-packages/pip/_internal/cli/base_command.pyRC   i   s    c         C@ s6   z$ |  j     |  j |  SWd  QXWd  t j   Xd  S(   N(   t   main_contextt   _maint   loggingt   shutdown(   R7   RA   (    (    s/   site-packages/pip/_internal/cli/base_command.pyt   mainn   s    c         C@ s'  |  j  t    |  _ |  j  t    |  j |  \ } } | j | j |  _ t d |  j d | j d | j	  } t
 j d  d k rฬ | j 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 rF|  j rFt   sFt j d  t
 j t  qFn  | j rt | j  | _ t | j  st j  d | j  d  | _ qn  zy) |  j! | |  } t" | t#  rฝ| 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
 rr} t j d |  t j& d d t' t, St. k
 rปt/ d d t
 j0 | t1 j2 k rทt3 j4 d t
 j0  n  t, St5 k
 r์t j d  t j& d d t' t, St6 k
 rt j d d t' t7 SXWd  |  j8 |  Xt9 S(   Nt	   verbosityt   no_colort   user_log_filei   i   sย   pip 21.0 will drop support for Python 2.7 in January 2021. 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 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. t   replacementt   gone_int   1t   PIP_NO_INPUTt    t   PIP_EXISTS_ACTIONs2   Could not find an activated virtualenv (required).s่   The directory '%s' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.s   Exception information:t   exc_infos   %ss    ERROR: Pipe to stdout was brokent   files   Operation cancelled by users
   Exception:(   i   i   (:   t   enter_contextR   R   RC   t   verboset   quietRI   R   RJ   t   logt   syst   version_infot   no_python_version_warningt   platformt   python_implementationR   R/   t   no_inputt   ost   environt   exists_actiont   joint   require_venvt   ignore_require_venvR   t   loggert   criticalt   exitR
   t	   cache_dirR   R   t   warningRB   t
   isinstancet   intR   t   strt   debugt   TrueR   R   R   R   R   R   R   t   printt   stderrRF   t   DEBUGt	   tracebackt	   print_exct   KeyboardInterruptt   BaseExceptionR	   R?   R   (   R7   RA   R>   t   level_numbert   messaget   statust   exc(    (    s/   site-packages/pip/_internal/cli/base_command.pyRE   v   s|    		

				
 	N(   t   __name__t
   __module__R/   R!   R+   Rd   R)   R?   RB   RC   RH   RE   (    (    (    s/   site-packages/pip/_internal/cli/base_command.pyR    9   s   	
			(<   R,   t
   __future__R    R   RF   t   logging.configR1   R_   R\   RY   Rr   t   pip._internal.cliR   t!   pip._internal.cli.command_contextR   t   pip._internal.cli.parserR   R   t   pip._internal.cli.status_codesR   R   R   R	   R
   t   pip._internal.exceptionsR   R   R   R   R   t   pip._internal.utils.deprecationR   t   pip._internal.utils.filesystemR   t   pip._internal.utils.loggingR   R   t   pip._internal.utils.miscR   R   t   pip._internal.utils.temp_dirR   R   t   pip._internal.utils.typingR   t   pip._internal.utils.virtualenvR   t   typingR   R   R   R   R   R   t   TempDirRegistryt   __all__t	   getLoggerRz   Re   R    (    (    (    s/   site-packages/pip/_internal/cli/base_command.pyt   <module>   s6   (("	