U
    «ÃT_  ã                   @   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Ú	formatterÚadd_help_optionÚnameÚdescriptionÚisolatedz
%s Options)Úsuperr   Ú__init__r    r   r   Ú__doc__r$   Úsummaryr   ÚparserÚ
capitalizeÚoptparseÚOptionGroupÚcmd_optsr   Úmake_option_groupÚgeneral_groupÚadd_option_group)Úselfr$   r*   r&   Ú	parser_kwÚoptgroup_nameÚgen_opts©Ú	__class__© úB/tmp/pip-unpacked-wheel-8u7dkzi1/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.
        Úno_indexN)ÚhasattrÚAssertionError)r3   Úoptionsr9   r9   r:   Úhandle_pip_version_checkR   s    z Command.handle_pip_version_checkc                 C   s   t ‚d S ©N)ÚNotImplementedError)r3   r>   Úargsr9   r9   r:   Úrun\   s    zCommand.runc                 C   s   | j  |¡S r@   )r+   Ú
parse_args©r3   rB   r9   r9   r:   rD   `   s    zCommand.parse_argsc              
   C   s>   z.|  ¡ � |  |¡W  5 Q R £ W ¢S Q R X W 5 t  ¡  X d S r@   )ÚloggingÚshutdownÚmain_contextÚ_mainrE   r9   r9   r:   Ú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r�tdd	d
dd� |jr dtjd< |jr¸d |j¡tjd< |jrÞ| jsÞtƒ sÞt d¡ t	 t¡ |j�rt|jƒ|_t|jƒ�st d|j¡ d |_�z¼z*|  !||¡}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_colorÚuser_log_fileé   )rN   é   zÁ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-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. )ÚreplacementÚgone_inz<--skip-requirements-regex is unsupported and will be removedzXmanage requirements/constraints files explicitly, possibly generating them from metadataz20.1i�  )rQ   rR   ÚissueÚ1ÚPIP_NO_INPUTú ÚPIP_EXISTS_ACTIONz2Could not find an activated virtualenv (required).zè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.zException information:T)Úexc_infoz%sz ERROR: Pipe to stdout was broken)ÚfilezOperation cancelled by userz
Exception:)8Úenter_contextr   rD   ÚverboseÚquietrK   r   rL   ÚlogÚsysÚversion_infoÚno_python_version_warningÚplatformÚpython_implementationr   Úskip_requirements_regexÚno_inputÚosÚenvironÚexists_actionÚjoinÚrequire_venvÚignore_require_venvr   ÚloggerÚcriticalÚexitr   Ú	cache_dirr   r   Úwarningr?   rC   Ú
isinstanceÚintr   ÚstrÚdebugr	   r   r   r   r   r   r   ÚprintÚstderrrF   ÚDEBUGÚ	tracebackÚ	print_excÚKeyboardInterruptÚBaseExceptionr   r
   )r3   rB   r>   Úlevel_numberÚmessageÚstatusÚexcr9   r9   r:   rI   m   s”    ýÿþÿüù
ÿ
ú 
zCommand._main)F)Ú__name__Ú
__module__Ú__qualname__r    rj   r(   r?   rC   rD   rJ   rI   Ú__classcell__r9   r9   r7   r:   r   2   s   
)8r)   Ú
__future__r   r   rF   Úlogging.configr-   re   ra   r^   rw   Zpip._internal.clir   Ú!pip._internal.cli.command_contextr   Úpip._internal.cli.parserr   r   Úpip._internal.cli.status_codesr   r	   r
   r   r   Úpip._internal.exceptionsr   r   r   r   r   Úpip._internal.utils.deprecationr   Úpip._internal.utils.filesystemr   Úpip._internal.utils.loggingr   r   Úpip._internal.utils.miscr   r   Úpip._internal.utils.temp_dirr   Úpip._internal.utils.typingr   Úpip._internal.utils.virtualenvr   Útypingr   r   r   r   Ú__all__Ú	getLoggerr   rk   r   r9   r9   r9   r:   Ú<module>   s4   
