U
    „}agò  ã                   @   sÒ   d Z ddlZddlZddlZddl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mZ d
dgZedœdd
„Zeee dœdd„Zee eeee f dœdd„ZdS )z=A single place for constructing and exposing the main parser
é    N)ÚListÚOptionalÚTuple)Úget_runnable_pip)Ú
cmdoptions)ÚConfigOptionParserÚUpdatingDefaultsHelpFormatter)Úcommands_dictÚget_similar_commands)ÚCommandError)Úget_pip_versionÚget_progÚcreate_main_parserÚparse_command)Úreturnc                  C   sl   t ddtƒ dtƒ d�} |  ¡  tƒ | _t tj| ¡}|  	|¡ d| _
dgdd„ t ¡ D ƒ }d	 |¡| _| S )
z1Creates and returns the main parser for pip's CLIz
%prog <command> [options]FÚglobal)ÚusageÚadd_help_optionÚ	formatterÚnameÚprogTÚ c                 S   s"   g | ]\}}|d ›d|j › �‘qS )Z27ú )Zsummary)Ú.0r   Zcommand_info© r   úU/var/www/html/publicvenv/lib/python3.8/site-packages/pip/_internal/cli/main_parser.pyÚ
<listcomp>)   s   ÿz&create_main_parser.<locals>.<listcomp>Ú
)r   r   r   Údisable_interspersed_argsr   Úversionr   Zmake_option_groupZgeneral_groupÚadd_option_groupÚmainr	   ÚitemsÚjoinÚdescription)ÚparserZgen_optsr$   r   r   r   r      s"    û

þ)Úpythonr   c                 C   sN   t j | ¡rJt j | ¡rFdD ]&}t j | |¡}t j |¡r|  S qn| S d S )N)z
bin/pythonzScripts/python.exe)ÚosÚpathÚexistsÚisdirr#   )r&   ZexeÚpyr   r   r   Úidentify_python_interpreter2   s    r,   )Úargsr   c              
   C   sŒ  t ƒ }| | ¡\}}|jrÄdtjkrÄt|jƒ}|d krFtd|j› �ƒ‚|tƒ g}| | ¡ dtjd< d}zt	 
|¡}|j}W n< t	jtfk
r¸ } ztd|› d|› �ƒ‚W 5 d }~X Y nX t |¡ |jrîtj |j¡ tj tj¡ t ¡  |�r|d dk�r t|ƒdk�r | ¡  t ¡  |d }	|	tk�rnt|	ƒ}
d	|	› d
�g}|
�r`| d|
› d
�¡ td |¡ƒ‚| d d … }| |	¡ |	|fS )NZ_PIP_RUNNING_IN_SUBPROCESSz$Could not locate Python interpreter Ú1r   zFailed to run pip under z: Úhelpé   zunknown command "ú"zmaybe you meant "z - )r   Ú
parse_argsr&   r'   Úenvironr,   r   r   ÚextendÚ
subprocessÚrunÚ
returncodeZSubprocessErrorÚOSErrorÚsysÚexitr   ÚstdoutÚwriteÚlinesepÚlenÚ
print_helpr	   r
   Úappendr#   Úremove)r-   r%   Zgeneral_optionsZ	args_elseZinterpreterZpip_cmdr7   ÚprocÚexcÚcmd_nameZguessÚmsgÚcmd_argsr   r   r   r   E   sJ    	

ÿþ



&
"

)Ú__doc__r'   r5   r9   Útypingr   r   r   Zpip._internal.build_envr   Zpip._internal.clir   Zpip._internal.cli.parserr   r   Úpip._internal.commandsr	   r
   Úpip._internal.exceptionsr   Zpip._internal.utils.miscr   r   Ú__all__r   Ústrr,   r   r   r   r   r   Ú<module>   s   