B Re& @sddlmZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z mZddlmZddlmZmZdd lmZerdd lmZmZmZmZmZmZmZmZeeeefZ d Z!d d Z"ddZ#ddZ$ddZ%dddZ&ddZ'dS))absolute_importN) shlex_quote)SpinnerInterface open_spinner)InstallationError)console_to_strstr_to_display)subprocess_logger) HiddenTextpath_to_display)MYPY_CHECK_RUNNING)AnyCallableIterableListMappingOptionalTextUnionz(----------------------------------------cGs6g}x,|D]$}t|tr$||q ||q W|S)z& Create a CommandArgs object. ) isinstancelistextendappend)args command_argsargr/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/utils/subprocess.py make_commands    rcCsddd|DS)z/ Format command arguments for display.  css,|]$}t|trtt|nt|VqdS)N)rr rstr).0rrrr 8sz&format_command_args..)join)rrrrformat_command_args-s r$cCsdd|DS)z= Return the arguments in their raw, unredacted form. cSs g|]}t|tr|jn|qSr)rr secret)r!rrrr Csz'reveal_command_args..r)rrrrreveal_command_args=sr'c CsDt|}t|dd}t|}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. z command bytes)desczCommand errored out with exit status {exit_status}: command: {command_display} cwd: {cwd_display} Complete output ({line_count} lines): {output}{divider}) exit_statuscommand_display cwd_display line_countoutputdivider)r$rr r#formatlen LOG_DIVIDER) cmd_argscwdlinesr*commandr+r,r.msgrrrmake_subprocess_output_errorGs   r8FraiseTc  Csd|dkr g}|dkrg}|r*tj} tj} n tj} tj} t| k} | oN|dk } |dkr`t|}| d|tj }|r| |x|D]}| |dqWyBt jt|t jt jt j||d}|jst|jst|jWn:tk r}z| rtd||Wdd}~XYnXg}xRt|j}|s6P|}||d| || r |sdt|q Wz |Wd|jr|jX|jo|j|k}| r|st|r|dn |d|rZ|dkr"| s | r t ||||jd }t!|d "|j|}t#|n8|d kr@t$d ||j|n|d krLnt%d"|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. NzRunning command %s)stderrstdinstdoutr4envz#Error %s while executing command %s errordoner9)r3r4r5r*zSCommand errored out with exit status {}: {} Check the logs for full command output.warnz$Command "%s" had error code %s in %signorez!Invalid value: on_returncode={!r}r))'r infologgingINFOdebugDEBUGgetEffectiveLevelr$osenvironcopyupdatepop subprocessPopenr'STDOUTPIPEr;AssertionErrorr<close Exceptioncriticalrreadlinerstriprspinwait returncodefinishr8r?r0rwarning ValueErrorr#)cmd show_stdoutr4 on_returncodeextra_ok_returncodes command_desc extra_environ unset_environspinnerlog_failed_cmdlog_subprocess used_levelshowing_subprocess use_spinnerr=nameprocexc all_outputlineproc_had_errorr7exc_msgrrrcall_subprocessqs                      rrcsdfdd }|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. Nc s(t}t||||dWdQRXdS)N)r4rcre)rrr)r^r4rcre)messagerrrunner s  z+runner_with_spinner_message..runner)NNr)rsrtr)rsrrunner_with_spinner_messages  ru) FNr9NNNNNT)( __future__rrDrIrNpip._vendor.six.movesrpip._internal.cli.spinnersrrpip._internal.exceptionsrpip._internal.utils.compatrrpip._internal.utils.loggingr pip._internal.utils.miscr r pip._internal.utils.typingr typingr rrrrrrrr Z CommandArgsr2rr$r'r8rrrurrrrs:     ( ,