U ʗRe#@sxddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z ddl mZddlmZmZddlmZddlmZmZddlmZerddlmZe e eefZe eeefed d d Ze e eefed d d Ze e eefe ed ddZde e eefee ede ee e e eefe eee ee ee eeed ddZ!eeddddZ"dS)N) TYPE_CHECKINGAnyCallableIterableListMappingOptionalUnion)escape)SpinnerInterface open_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger) HiddenText)Literal)argsreturncGs2g}|D]$}t|tr"||q||q|S)z& Create a CommandArgs object. ) isinstancelistextendappend)r command_argsargr/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py make_command s    rcCsddd|DS)z/ Format command arguments for display.  css0|](}t|trtt|nt|VqdS)N)rrshlexquotestr.0rrrr :sz&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 Dsz'reveal_command_args..rr%rrrreveal_command_args@sr)FraiseTz"Literal["raise", "warn", "ignore"]) cmd show_stdoutcwd on_returncodeextra_ok_returncodes extra_environ unset_environspinnerlog_failed_cmd stdout_only command_descrc  Cs|dkr g}|dkrg}|r*tj} tj} n tj} t} t| k} | oL|dk }| d| tj }|rp| ||D]}| |dqtz0t j t|t jt j| st jnt j||dd}Wn6tk r}z|rtd|| W5d}~XYnXg}| s|jst|jst|j|j}|s.qh|}||d| ||r|s\t|qz |W5|jr|jXd|}nT|\}}|D]}| |q|||D]}| |q|||}|jo|j|k}|r(|s t|r| dn | d |r|d krt!| |j| sJ|ndd }|rt"d |tjd t#t$|ddidtjdt#|pdddid|n8|dkrt%d| |j|n|dkrnt&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 %s errordoner*)command_description exit_code output_linesz[present-rich] %sz*[bold magenta]full command[/]: [blue]%s[/]markupT)extraz[bold magenta]cwd[/]: %sz [inherit]warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=)'rinfologgingINFOverbosergetEffectiveLevelosenvironcopyupdatepop subprocessPopenr)PIPESTDOUT Exceptioncriticalr8AssertionErrorr7closereadlinerstriprspinwaitr$ 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                               rr).N)messagercs2dttttttttfddfdd }|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. N)r+r-r0rc s*t}t||||dW5QRXdS)N)r5r-r0r2)r rr)r+r-r0r2rsrrrunners z+runner_with_spinner_message..runner)NN)rr rrr)rsrurrtrrunner_with_spinner_messages rv) FNr*NNNNTF)#rHrLrrQtypingrrrrrrrr Zpip._vendor.rich.markupr pip._internal.cli.spinnersr r pip._internal.exceptionsr pip._internal.utils.loggingrrpip._internal.utils.miscrrr CommandArgsrr&r)boolintrrrvrrrrsP(        )