a ReJ'@sddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZmZddlmZerddlmZe e eefZdZe eeefed d d Ze e eefed d d Ze e eefe ed ddZe e eefe ee eeedddZde e eefe e ede eee ee e eefe eee ee e e e ed ddZ!eeddddZ"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)r command_argsargr/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/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_args2s r%cCsdd|DS)z= Return the arguments in their raw, unredacted form. cSs g|]}t|tr|jn|qSr)rrsecretr rrr Ez'reveal_command_args..rr$rrrreveal_command_argsAsr))cmd_argscwdlines exit_statusrcCs0t|}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-command_display cwd_display line_countoutputdivider)r%r#formatlen LOG_DIVIDER)r*r+r,r-commandr2msgrrrmake_subprocess_output_errorHs   r9FraiseTz"Literal["raise", "warn", "ignore"]) cmd show_stdoutr+ on_returncodeextra_ok_returncodes command_desc extra_environ unset_environspinnerlog_failed_cmd stdout_onlyrc  Cs|dur g}|durg}|r*tj} tj} n tj} t} t| k} | oL|du}|dur^t|}| d|tj }|r| ||D]}| |dqz0t jt|t jt j| st jnt j||dd}Wn8ty}z | rtd||WYd}~n d}~00g}| s|jsJ|js"J|j|j}|s@qz|}||d| ||r,|snJ|q,z|W|jr|jn|jr|j0d|}nT|\}}|D]}| |q|||D]}| |q|||}|jo|j|v}|rL|s0J|rB| dn | d |r|d kr| s| rt!||||jd }t"|t#|j|n8|d krt$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 r.errordoner:)r*r+r,r-warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=)&rinfologgingINFOverboser getEffectiveLevelr%osenvironcopyupdatepop subprocessPopenr)PIPESTDOUT ExceptioncriticalrGrFclosereadlinerstriprspinwaitr# communicate splitlines returncodefinishr9rLr warning ValueError)r;r<r+r=r>r?r@rArBrCrDlog_subprocess used_levelshowing_subprocess use_spinnerrInameprocexc all_outputliner2outerrout_lineerr_lineproc_had_errorr8rrrcall_subprocessks                              ry).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+r@rcs<t }t||||dWdn1s.0YdS)N)r+r@rB)r ry)r;r+r@rBrzrrrunners z+runner_with_spinner_message..runner)NN)rrrrr)rzr|rr{rrunner_with_spinner_message s  r}) FNr:NNNNNTF)#rQrUrrZtypingrrrrrrrr pip._internal.cli.spinnersr r pip._internal.exceptionsr pip._internal.utils.loggingr rpip._internal.utils.miscrrr CommandArgsr6rr%r)intr9boolryr}rrrrs^(      %   #