U
    Eh                     @   sR  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) ddl*m+Z+ ddl,m-Z- e+r.ddl.m/Z/m0Z0m1Z1 ddlm2Z2 dgZ3e4e5Z6G dd deZ7dS )z(Base Command class, and related routines    )absolute_importprint_functionN)
cmdoptions)CommandContextMixIn)ConfigOptionParserUpdatingDefaultsHelpFormatter)ERRORPREVIOUS_BUILD_DIR_ERRORSUCCESSUNKNOWN_ERRORVIRTUALENV_NOT_FOUND)
BadCommandCommandErrorInstallationErrorPreviousBuildDirErrorUninstallationError)
deprecated)check_path_owner)BrokenStdoutLoggingErrorsetup_logging)get_prognormalize_path)global_tempdir_manager)MYPY_CHECK_RUNNING)running_under_virtualenv)ListTupleAny)ValuesCommandc                       sN   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
  ZS )r   NFc                    s   t t|   | jdt |f t d|| j|d}|| _|| _t	f || _
d| j  }t| j
|| _ttj| j
}| j
| d S )Nz%s %sF)usageprog	formatterZadd_help_optionnamedescriptionisolatedz
%s Options)superr   __init__r    r   r   __doc__r#   summaryr   parser
capitalizeoptparseZOptionGroupZcmd_optsr   Zmake_option_groupZgeneral_groupZadd_option_group)selfr#   r)   r%   Z	parser_kwZoptgroup_nameZgen_opts	__class__ D./venv/lib/python3.8/site-packages/pip/_internal/cli/base_command.pyr'   6   s&    
zCommand.__init__c                 C   s   t |drtdS )zf
        This is a no-op so that commands by default do not do the pip version
        check.
        Zno_indexN)hasattrAssertionError)r-   optionsr0   r0   r1   handle_pip_version_checkR   s    z Command.handle_pip_version_checkc                 C   s   t d S N)NotImplementedError)r-   r4   argsr0   r0   r1   run\   s    zCommand.runc                 C   s   | j |S r6   )r*   
parse_argsr-   r8   r0   r0   r1   r:   `   s    zCommand.parse_argsc              
   C   s>   z.|   | |W  5 Q R  W S Q R X W 5 t   X d S r6   )loggingZshutdownZmain_context_mainr;   r0   r0   r1   maine   s    
$zCommand.mainc              
   C   s  |  t  | |\}}|j|j | _t| j|j|jd}t	j
d d dkrz|jszd}t dkrld| }t|d d d |jrtdd	d
dd |jrdtjd< |jrd|jtjd< |jr| jst std t	t |jrt|j|_t|jstd|j d |_zz*| !||}t"|t#r<|W W S W n t$k
r } z.tt%| tj&ddd t' W Y W RS d }~X Y n> t(t)t*fk
r } z.tt%| tj&ddd t+ W Y W  S d }~X Y n t,k
r* } z*td| tj&ddd t+ W Y W S d }~X Y n t-k
rn   t.dt	j/d |t0j1krbt2j3t	j/d t+ Y W fS  t4k
r   td tj&ddd t+ Y W 2S  t5k
r   tjddd t6 Y W S X W 5 |  | X t7S )N)	verbosityno_colorZuser_log_file   )rA      zA 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-supportZ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. )replacementgone_inz<--skip-requirements-regex is unsupported and will be removedzXmanage requirements/constraints files explicitly, possibly generating them from metadataz20.1i  )rC   rD   Zissue1ZPIP_NO_INPUT Z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.zException information:T)exc_infoz%sz ERROR: Pipe to stdout was broken)filezOperation cancelled by userz
Exception:)8enter_contextr   r:   verbosequietr?   r   r@   logsysversion_infoZno_python_version_warningplatformZpython_implementationr   Zskip_requirements_regexZno_inputosenvironZexists_actionjoinZrequire_venvignore_require_venvr   loggerZcriticalexitr   	cache_dirr   r   Zwarningr5   r9   
isinstanceintr   strdebugr	   r   r   r   r   r   r   printstderrr<   DEBUG	traceback	print_excKeyboardInterruptBaseExceptionr   r
   )r-   r8   r4   Zlevel_numbermessagestatusexcr0   r0   r1   r=   m   s    

 
zCommand._main)F)__name__
__module____qualname__r    rS   r'   r5   r9   r:   r>   r=   __classcell__r0   r0   r.   r1   r   2   s   
)8r(   Z
__future__r   r   r<   Zlogging.configr,   rP   rO   rM   r^   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   r   Zpip._internal.exceptionsr   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   Zpip._internal.utils.typingr   Zpip._internal.utils.virtualenvr   typingr   r   r   r   __all__Z	getLoggerre   rT   r   r0   r0   r0   r1   <module>   s4   
