
0c@_j"                 @   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 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" 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 l0 m1 Z1 m2 Z2 m3 Z3 m4 Z4 d d l m5 Z5 d d l) m6 Z7 d g Z8 e j9 e:  Z; Gd d   d e  Z< d S)z(Base Command class, and related routines    )absolute_importprint_functionN)
cmdoptions)CommandContextMixIn)ConfigOptionParserUpdatingDefaultsHelpFormatter)ERRORPREVIOUS_BUILD_DIR_ERRORUNKNOWN_ERRORVIRTUALENV_NOT_FOUND)
BadCommandCommandErrorInstallationErrorNetworkConnectionErrorPreviousBuildDirErrorSubProcessErrorUninstallationError)
deprecated)check_path_owner)BrokenStdoutLoggingErrorsetup_logging)get_prognormalize_path)global_tempdir_managertempdir_registry)MYPY_CHECK_RUNNING)running_under_virtualenv)ListOptionalTupleAny)Values)TempDirectoryTypeRegistryCommandc                   sy   e  Z d  Z d Z d Z d   f d d  Z d d   Z d d   Z d	 d
   Z d d   Z	 d d   Z
 d d   Z   S)r#   NFc                s   t  t |   j   d |  j d d j t   |  d t   d d d | d |  j d	 | i } | |  _ | |  _	 t
 |   |  _ d  |  _ d
 j |  j j    } t j |  j |  |  _ t j t j |  j  } |  j j |  |  j   d  S)Nusageprogz{} {}	formatteradd_help_optionFnamedescriptionisolatedz
{} Options)superr#   __init__r$   formatr   r   __doc__r(   summaryr   parserr   
capitalizeoptparseOptionGroupcmd_optsr   make_option_groupgeneral_groupadd_option_groupadd_options)selfr(   r/   r*   	parser_kwoptgroup_namegen_opts)	__class__ =/tmp/pip-build-jynh7p1z/pip/pip/_internal/cli/base_command.pyr,   >   s&    						zCommand.__init__c             C   s   d  S)Nr>   )r9   r>   r>   r?   r8   ^   s    zCommand.add_optionsc             C   s   t  | d  s t  d S)zf
        This is a no-op so that commands by default do not do the pip version
        check.
        no_indexN)hasattrAssertionError)r9   optionsr>   r>   r?   handle_pip_version_checkb   s    z Command.handle_pip_version_checkc             C   s
   t   d  S)N)NotImplementedError)r9   rC   argsr>   r>   r?   runl   s    zCommand.runc             C   s   |  j  j |  S)N)r0   
parse_args)r9   rF   r>   r>   r?   rH   p   s    zCommand.parse_argsc             C   s7   z% |  j     |  j |  SWd  QRXWd  t j   Xd  S)N)Zmain_context_mainloggingshutdown)r9   rF   r>   r>   r?   mainu   s    zCommand.mainc             C   s  |  j  t    |  _ |  j  t    |  j |  \ } } | j | j |  _ t d |  j d | j d | j	  } t
 j d  d  d" k r | j r d } t j   d k r d | } t | d	 d  d
 d  | j r d t j d <| j rd j | j  t j d <| j r:|  j r:t   s:t j d  t
 j t  | j rt | j  | _ t | j  st j d | j  d  | _ t  | d d   rt d d d	 d d
 d d d  d | j! k rt j d  t
 j t"  zy/ |  j# | |  } t$ | t%  st&  | SWnt' k
 r]} z/ t j t( |   t j) d d d t* SWYd  d  } ~ XnPt+ t, t- t. t/ f k
 r} z/ t j t( |   t j) d d d t" SWYd  d  } ~ Xn t0 k
 r} z, t j d |  t j) d d d t" SWYd  d  } ~ Xn t1 k
 rOt2 d d t
 j3 | t4 j5 k rGt6 j7 d t
 j3  t" SYn^ t8 k
 rt j d   t j) d d d t" SYn) t9 k
 rt j d! d d t: SYn XWd  |  j; |  Xd  S)#N	verbosityno_colorZuser_log_file      zpip 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-supportCPythonz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. replacementZgone_in1PIP_NO_INPUT PIP_EXISTS_ACTIONz2Could not find an activated virtualenv (required).zThe 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.	build_dirreasonzBThe -b/--build/--build-dir/--build-directory option is deprecated.zOuse the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-cleanz20.3Zissuei   resolverzs--unstable-feature=resolver is no longer supported, and has been replaced with --use-feature=2020-resolver instead.zException information:exc_infoTz%sz ERROR: Pipe to stdout was brokenfilezOperation cancelled by userz
Exception:)rO   rP   )<enter_contextr   r   rH   verbosequietrM   r   rN   logsysversion_infoZno_python_version_warningplatformpython_implementationr   no_inputosenvironexists_actionjoinrequire_venvignore_require_venvr   loggercriticalexitr   	cache_dirr   r   warninggetattrZunstable_featuresr   rG   
isinstanceintrB   r   strdebugr	   r   r   r   r   r   r   r   printstderrrJ   DEBUG	traceback	print_excKeyboardInterruptBaseExceptionr
   rD   )r9   rF   rC   Zlevel_numbermessagestatusexcr>   r>   r?   rI   }   s    		
				
	
zCommand._main)__name__
__module____qualname__r$   rj   r,   r8   rD   rG   rH   rL   rI   r>   r>   )r=   r?   r#   :   s    
)=r.   
__future__r   r   rJ   logging.configr2   re   rb   r`   rx   Zpip._internal.clir   Z!pip._internal.cli.command_contextr   Zpip._internal.cli.parserr   r   Zpip._internal.cli.status_codesr   r	   r
   r   Zpip._internal.exceptionsr   r   r   r   r   r   r   Zpip._internal.utils.deprecationr   Zpip._internal.utils.filesystemr   Zpip._internal.utils.loggingr   r   Zpip._internal.utils.miscr   r   Zpip._internal.utils.temp_dirr   r   Zpip._internal.utils.typingr   Zpip._internal.utils.virtualenvr   Ztypingr   r   r   r    r!   r"   ZTempDirRegistry__all__	getLoggerr   rk   r#   r>   r>   r>   r?   <module>   s6   "4	"	