o g#@sddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z ddl mZddlmZmZddlmZddlmZmZddlmZerNddlmZe e eefZd e eeefd efd d Zd e e eefd efd dZd e e eefd e efddZ         d&de e eefdede eddde ee de e eefde eede ede ede eded efd d!Z!d"ed ed#fd$d%Z"dS)'N) TYPE_CHECKINGAnyCallableIterableListMappingOptionalUnion)escape)SpinnerInterface open_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger) HiddenText)LiteralargsreturncGs2g}|D]}t|tr||q||q|S)z& Create a CommandArgs object. ) isinstancelistextendappend)r command_argsargr@/usr/lib/python3/dist-packages/pip/_internal/utils/subprocess.py make_command s    rcCsddd|DS)z/ Format command arguments for display.  css2|]}t|trtt|nt|VqdS)N)rrshlexquotestr.0rrrr :s  z&format_command_args..)joinrrrrformat_command_args1s r&cCsdd|DS)z= Return the arguments in their raw, unredacted form. cSs g|] }t|tr |jn|qSr)rrsecretr!rrr Ds z'reveal_command_args..rr%rrrreveal_command_args@sr)FraiseTcmd show_stdoutcwd on_returncodez"Literal["raise", "warn", "ignore"]extra_ok_returncodes extra_environ unset_environspinnerlog_failed_cmd stdout_only command_descc  Cs|durg}|dur g}|rtj} tj} ntj} t} t| k} | o&|du}| d| tj }|r8| ||D]}| |dq:zt j t|t jt j| sRt jnt j||dd}Wntyq}z |rltd|| d}~wwg}| s|js{J|jsJ|j |j}|sn|}||d| ||r|sJ|qz|W|jr|jn |jr|jwwd|}n(|\}}|D]}| |q|||D]}| |q|||}|jo|j|v}|r |sJ|r|d n|d |rh|d krIt | |j| s|ndd }|rGt!d |tjdt"t#|ddidtjdt"|p@dddid||dkrYt$d| |j||S|dkra |St%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. NzRunning command %sbackslashreplace)stdinstdoutstderrr-enverrorsz#Error %s while executing command %sT errordoner*)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 %signorezInvalid value: on_returncode=)&rinfologgingINFOverbosergetEffectiveLevelosenvironcopyupdatepop subprocessPopenr)PIPESTDOUT Exceptioncriticalr8r7closereadlinerstriprspinwaitr$ communicate splitlines returncodefinishr r>r r&warning ValueError)r+r,r-r.r/r0r1r2r3r4r5log_subprocess used_levelshowing_subprocess use_spinnerr:nameprocexc all_outputlineoutputouterrout_lineerr_lineproc_had_errorr>rrrcall_subprocessGs                              rqmessage).Nc s<  ddttdttdttttfddffdd }|S) zProvide 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-r0rcs@t}t||||dWddS1swYdS)N)r5r-r0r2)r rq)r+r-r0r2rrrrrunners "z+runner_with_spinner_message..runner)NN)rr rrr)rrrtrrsrrunner_with_spinner_messages ru) FNr*NNNNTF)#rHrLrrQtypingrrrrrrrr pip._vendor.rich.markupr pip._internal.cli.spinnersr r pip._internal.exceptionsr pip._internal.utils.loggingrrpip._internal.utils.miscrrr CommandArgsrr&r)boolintrqrurrrrsh(    "       )