o
    Ëý°je  ã                   @   s@  d 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
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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&m'Z' ddl(m)Z)m*Z* ddl+m,Z- ddl+m.Z.m/Z/ ddl0m1Z1 dgZ2e 3e4¡Z5G dd„ deƒZ6dS )z(Base Command class, and related routinesé    N)ÚValues)ÚAnyÚCallableÚListÚOptionalÚTuple)Ú
cmdoptions)ÚCommandContextMixIn)ÚConfigOptionParserÚUpdatingDefaultsHelpFormatter)ÚERRORÚPREVIOUS_BUILD_DIR_ERRORÚUNKNOWN_ERRORÚVIRTUALENV_NOT_FOUND)Ú
BadCommandÚCommandErrorÚDiagnosticPipErrorÚInstallationErrorÚNetworkConnectionErrorÚPreviousBuildDirErrorÚUninstallationError)Úcheck_path_owner)ÚBrokenStdoutLoggingErrorÚsetup_logging)Úget_progÚnormalize_path)ÚTempDirectoryTypeRegistry)Úglobal_tempdir_managerÚtempdir_registry)Úrunning_under_virtualenvÚCommandc                	       sÎ   e Zd ZU dZeed< dZeed< ddedededd	f‡ fd
d„Zddd„Z	de
dd	fdd„Zde
dee defdd„Zdee dee
ee f fdd„Zdee defdd„Zdee defdd„Z‡  ZS )r    Ú ÚusageFÚignore_require_venvÚnameÚsummaryÚisolatedÚreturnNc              	      sŽ   t ƒ  ¡  || _|| _t| jtƒ › d|› �tƒ d|| j|d�| _	d | _
| j ¡ › d�}t | j	|¡| _t tj| j	¡}| j	 |¡ |  ¡  d S )Nú F)r"   ÚprogÚ	formatterÚadd_help_optionr$   Údescriptionr&   z Options)ÚsuperÚ__init__r$   r%   r
   r"   r   r   Ú__doc__Úparserr   Ú
capitalizeÚoptparseÚOptionGroupÚcmd_optsr   Úmake_option_groupÚgeneral_groupÚadd_option_groupÚadd_options)Úselfr$   r%   r&   Úoptgroup_nameÚgen_opts©Ú	__class__© ú‘/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.pyr.   /   s*   
ù
þzCommand.__init__c                 C   s   d S ©Nr>   )r9   r>   r>   r?   r8   M   ó   zCommand.add_optionsÚoptionsc                 C   s   t |dƒrJ ‚dS )zf
        This is a no-op so that commands by default do not do the pip version
        check.
        Úno_indexN)Úhasattr)r9   rB   r>   r>   r?   Úhandle_pip_version_checkP   s   z Command.handle_pip_version_checkÚargsc                 C   s   t ‚r@   )ÚNotImplementedError)r9   rB   rF   r>   r>   r?   ÚrunY   rA   zCommand.runc                 C   s   | j  |¡S r@   )r0   Ú
parse_args©r9   rF   r>   r>   r?   rI   \   s   zCommand.parse_argsc                 C   sV   z%|   ¡ � |  |¡W  d   ƒ W t ¡  S 1 sw   Y  W t ¡  d S t ¡  w r@   )Úmain_contextÚ_mainÚloggingÚshutdownrJ   r>   r>   r?   Úmain`   s   
ÿ
ýzCommand.mainc              	      s>  |   tƒ ¡| _|   tƒ ¡ |  |¡\}}|j|j | _t| j|j|j	d�‰ |j
r-dtjd< |jr9d |j¡tjd< |jrL| jsLtƒ sLt d¡ t t¡ |jrdt|jƒ|_t|jƒsdt d|j¡ d |_d|jv rnt d	¡ d
tdtf dtdtf f‡ fdd„}z|js‹|| jƒ}n| j}|||ƒW |   |¡ S |   |¡ w )N)Ú	verbosityÚno_colorÚuser_log_fileÚ1ÚPIP_NO_INPUTr(   Ú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 should use sudo's -H flag.z2020-resolverz”--use-feature=2020-resolver no longer has any effect, since it is now the default dependency resolver in pip. This will become an error in pip 21.0.Úrun_func.r'   c                    s&   t  ˆ ¡dtdtf‡‡ fdd„ƒ}|S )NrF   r'   c                     s´  zˆ| Ž }t |tƒsJ ‚|W S  ty/ } zt d|¡ tjddd� tW  Y d }~S d }~w tyP } zt t	|ƒ¡ tjddd� t
W  Y d }~S d }~w ttttfyu } zt t	|ƒ¡ tjddd� tW  Y d }~S d }~w ty• } zt d|¡ tjddd� tW  Y d }~S d }~w ty²   tdtjd� ˆ tjkr®tjtjd� t Y S  tyÈ   t d¡ tjddd� t Y S  tyÙ   tjd	dd� t Y S w )
Nz[present-diagnostic] %szException information:T)Úexc_infoz%sz ERROR: Pipe to stdout was broken)ÚfilezOperation cancelled by userz
Exception:)Ú
isinstanceÚintr   ÚloggerÚerrorÚdebugr   r   ÚcriticalÚstrr   r   r   r   r   r   r   ÚprintÚsysÚstderrrM   ÚDEBUGÚ	tracebackÚ	print_excÚKeyboardInterruptÚBaseExceptionr   )rF   ÚstatusÚexc)Úlevel_numberrV   r>   r?   Úexc_logging_wrapper¢   sT   €€ü€€

ýzLCommand._main.<locals>.intercepts_unhandled_exc.<locals>.exc_logging_wrapper)Ú	functoolsÚwrapsr   rZ   )rV   rk   ©rj   )rV   r?   Úintercepts_unhandled_excŸ   s   0z/Command._main.<locals>.intercepts_unhandled_exc)!Úenter_contextr   r   rI   ÚverboseÚquietrP   r   rQ   ÚlogÚno_inputÚosÚenvironÚexists_actionÚjoinÚrequire_venvr#   r   r[   r^   ra   Úexitr   Ú	cache_dirr   r   ÚwarningÚfeatures_enabledr   rZ   Ú
debug_moderH   rE   )r9   rF   rB   ro   rH   r>   rn   r?   rL   g   sP   ý




ú
ÿ
ÿ
þ6
zCommand._main)F)r'   N)Ú__name__Ú
__module__Ú__qualname__r"   r_   Ú__annotations__r#   Úboolr.   r8   r   rE   r   rZ   rH   r   rI   rO   rL   Ú__classcell__r>   r>   r<   r?   r    +   s   
  
	")7r/   rl   rM   Úlogging.configr2   ru   ra   rd   r   Útypingr   r   r   r   r   Úpip._internal.clir   Ú!pip._internal.cli.command_contextr	   Úpip._internal.cli.parserr
   r   Úpip._internal.cli.status_codesr   r   r   r   Úpip._internal.exceptionsr   r   r   r   r   r   r   Úpip._internal.utils.filesystemr   Úpip._internal.utils.loggingr   r   Úpip._internal.utils.miscr   r   Úpip._internal.utils.temp_dirr   ÚTempDirRegistryr   r   Úpip._internal.utils.virtualenvr   Ú__all__Ú	getLoggerr   r[   r    r>   r>   r>   r?   Ú<module>   s0    $	
