o EcJ'@sddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZmZddlmZerHddlmZe e eefZdZd e eeefd efd d Zd e e eefd efd dZd e e eefd e efddZde e eefde ede eded ef ddZ          d+de e eefde de eddde eede ed e e eefd!e eed"e ed#e e d$e e d efd%d&Z!d'ed ed(fd)d*Z"dS),N) TYPE_CHECKINGAnyCallableIterableListMappingOptionalUnion)SpinnerInterface open_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger) HiddenText)Literalz(----------------------------------------argsreturncGs2g}|D]}t|tr||q||q|S)z& Create a CommandArgs object. ) isinstancelistextendappend)rZ command_argsargrQ/opt/alt/python310/lib/python3.10/site-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_args2s r$cCsdd|DS)z= Return the arguments in their raw, unredacted form. cSs g|] }t|tr |jn|qSr)rrZsecretrrrr Es z'reveal_command_args..rr#rrrreveal_command_argsAsr&cmd_argscwdlines exit_statuscCs0t|}d|}dj|||t||td}|S)z Create and return the error message to use to log a subprocess error with command output. :param lines: A list of lines, each ending with a newline. zCommand errored out with exit status {exit_status}: command: {command_display} cwd: {cwd_display} Complete output ({line_count} lines): {output}{divider})r*Zcommand_displayZ cwd_displayZ line_countoutputZdivider)r$r"formatlen LOG_DIVIDER)r'r(r)r*Zcommandr,msgrrrmake_subprocess_output_errorHs r1FraiseTcmd show_stdout on_returncodez"Literal["raise", "warn", "ignore"]extra_ok_returncodes command_desc extra_environ unset_environspinnerlog_failed_cmd stdout_onlyc  Cs|durg}|dur g}|rtj} tj} ntj} t} t| k} | o&|du}|dur/t|}| d|tj }|r@| ||D]}| |dqBzt jt|t jt j| sZt jnt j||dd}Wntyy}z | rttd||d}~wwg}| s|j |j}|sn|}||d| ||r|qz|W|jr|jn |jr|jwwd|}n(|\}}|D]}| |q|||D]}| |q|||}|jo|j|v}|r|r| d n| d |rB|d kr#| s| rt!||||jd }t"|t#|j||d kr3t$d||j||S|dkr; |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 r+errorZdoner2)r'r(r)r*warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=)&rinfologgingINFOverboser ZgetEffectiveLevelr$osenvironcopyupdatepop subprocessPopenr&PIPEZSTDOUT ExceptionZcriticalr>closer?readlinerstriprZspinwaitr"Z communicate splitlines returncodeZfinishr1rDr Zwarning ValueError)r3r4r(r5r6r7r8r9r:r;r<Zlog_subprocessZ used_levelZshowing_subprocessZ use_spinnerrAnameprocexcZ all_outputliner,outerrZout_lineZerr_lineZproc_had_errorr0rrrcall_subprocessks                           ramessage).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. Nr3r(r8rcs>t}t||||dWddS1swYdS)N)r(r8r:)r ra)r3r(r8r:rbrrrunners "z+runner_with_spinner_message..runner)NN)rrrrr)rbrdrrcrrunner_with_spinner_message s  re) FNr2NNNNNTF)#rHrKrrPtypingrrrrrrrr Zpip._internal.cli.spinnersr r Zpip._internal.exceptionsr Zpip._internal.utils.loggingr rZpip._internal.utils.miscrrrZ CommandArgsr/rr$r&intr1boolrarerrrrs(   " %      #