o
    Ëý°jÞ#  ã                   @   s¨  d dl Z d dlZd dlZd dlZd dlmZ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 d dlmZmZ d dlmZ erNd dlmZ e	eeef  Zd	eeeef d
efdd„Zd	ee	e ef d
efdd„Zd	ee	e ef d
e	e fdd„Z									d&dee	e ef dedee dddeee   dee
eef  deee  dee dee dee ded
efd d!„Z!d"ed
ed# fd$d%„Z"dS )'é    N)ÚTYPE_CHECKINGÚAnyÚCallableÚIterableÚListÚMappingÚOptionalÚUnion)Úescape)ÚSpinnerInterfaceÚopen_spinner)ÚInstallationSubprocessError)ÚVERBOSEÚsubprocess_logger)Ú
HiddenText)ÚLiteralÚargsÚreturnc                  G   s2   g }| D ]}t |tƒr| |¡ q| |¡ q|S )z&
    Create a CommandArgs object.
    )Ú
isinstanceÚlistÚextendÚappend)r   Úcommand_argsÚarg© r   ú‘/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/utils/subprocess.pyÚmake_command    s   
r   c                 C   s   d  dd„ | D ƒ¡S )z/
    Format command arguments for display.
    ú c                 s   s2   � | ]}t |tƒrt t|ƒ¡nt |¡V  qd S )N)r   r   ÚshlexÚquoteÚstr©Ú.0r   r   r   r   Ú	<genexpr>:   s
   €  ÿ
ÿz&format_command_args.<locals>.<genexpr>)Újoin©r   r   r   r   Úformat_command_args1   s   
	þr&   c                 C   s   dd„ | D ƒS )z=
    Return the arguments in their raw, unredacted form.
    c                 S   s    g | ]}t |tƒr|jn|‘qS r   )r   r   Úsecretr!   r   r   r   Ú
<listcomp>D   s     z'reveal_command_args.<locals>.<listcomp>r   r%   r   r   r   Úreveal_command_args@   s   r)   FÚraiseTÚcmdÚshow_stdoutÚcwdÚon_returncodez"Literal["raise", "warn", "ignore"]Úextra_ok_returncodesÚextra_environÚunset_environÚspinnerÚlog_failed_cmdÚstdout_onlyÚcommand_descc
             
   C   sÔ  |du rg }|du rg }|rt j}tj}nt j}t}t  ¡ |k}| o&|du}|d|
ƒ tj 	¡ }|r8| 
|¡ |D ]}| |d¡ q:ztjt| ƒtjtj|	sRtjntj||dd�}W n tyq } z
|rlt  d||
¡ ‚ d}~ww g }|	sÇ|js{J ‚|js€J ‚|j ¡  	 |j ¡ }|sŽn| ¡ }| |d ¡ ||ƒ |r§|s£J ‚| ¡  q†z| ¡  W |jr¶|j ¡  n
|jrÀ|j ¡  w w d |¡}n(| ¡ \}}| ¡ D ]}||ƒ qÑ| |¡ | ¡ D ]}||ƒ qá| |¡ |}|joö|j|v}|�r|sþJ ‚|�r| d	¡ n| d
¡ |�rh|dk�rIt |
|j|�s|ndd�}|�rGt  !d|¡ t jdt"t#| ƒƒddid� t jdt"|�p@dƒddid� |‚|dk�rYt  $d|
|j|¡ |S |dk�ra	 |S t%d|›�ƒ‚|S )aÍ  
    Args:
      show_stdout: if true, use INFO to log the subprocess's stderr and
        stdout streams.  Otherwise, use DEBUG.  Defaults to False.
      extra_ok_returncodes: an iterable of integer return codes that are
        acceptable, in addition to 0. Defaults to None, which means [].
      unset_environ: an iterable of environment variable names to unset
        prior to calling subprocess.Popen().
      log_failed_cmd: if false, failed commands are not logged, only raised.
      stdout_only: if true, return only stdout, else return both. When true,
        logging of both stdout and stderr occurs when the subprocess has
        terminated, else logging occurs as subprocess output is produced.
    NzRunning command %sÚbackslashreplace)ÚstdinÚstdoutÚstderrr-   ÚenvÚerrorsz#Error %s while executing command %sTÚ
Ú ÚerrorÚdoner*   )Úcommand_descriptionÚ	exit_codeÚoutput_linesz[present-diagnostic] %sz*[bold magenta]full command[/]: [blue]%s[/]Úmarkup)Úextraz[bold magenta]cwd[/]: %sz	[inherit]Úwarnz$Command "%s" had error code %s in %sÚignorezInvalid value: on_returncode=)&r   ÚinfoÚloggingÚINFOÚverboser   ÚgetEffectiveLevelÚosÚenvironÚcopyÚupdateÚpopÚ
subprocessÚPopenr)   ÚPIPEÚSTDOUTÚ	ExceptionÚcriticalr8   r7   ÚcloseÚreadlineÚrstripr   ÚspinÚwaitr$   ÚcommunicateÚ
splitlinesÚ
returncodeÚfinishr   r>   r
   r&   ÚwarningÚ
ValueError)r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   Úlog_subprocessÚ
used_levelÚshowing_subprocessÚuse_spinnerr:   ÚnameÚprocÚexcÚ
all_outputÚlineÚoutputÚoutÚerrÚout_lineÚerr_lineÚproc_had_errorr>   r   r   r   Úcall_subprocessG   sÚ   



ø
ý€ù



ô

€ÿÿ





ý
ýý
ü

üÿrq   Úmessage).Nc              
      s<   		ddt t dtt dttttf  ddf‡ fdd„}|S )	zÜProvide a subprocess_runner that shows a spinner message.

    Intended for use with for pep517's Pep517HookCaller. Thus, the runner has
    an API that matches what's expected by Pep517HookCaller.subprocess_runner.
    Nr+   r-   r0   r   c                    s@   t ˆ ƒ�}t| ˆ |||d� W d   ƒ d S 1 sw   Y  d S )N)r5   r-   r0   r2   )r   rq   )r+   r-   r0   r2   ©rr   r   r   Úrunnerö   s   
û"ÿz+runner_with_spinner_message.<locals>.runner)NN)r   r    r   r   r   )rr   rt   r   rs   r   Úrunner_with_spinner_messageï   s   	ýÿþýüru   )	FNr*   NNNNTF)#rH   rL   r   rQ   Útypingr   r   r   r   r   r   r   r	   Úpip._vendor.rich.markupr
   Úpip._internal.cli.spinnersr   r   Úpip._internal.exceptionsr   Úpip._internal.utils.loggingr   r   Úpip._internal.utils.miscr   r   r    ÚCommandArgsr   r&   r)   ÚboolÚintrq   ru   r   r   r   r   Ú<module>   sh    ("	öÿþýü
ûú
ùø	÷
öô
ó )