U .e& @sddlmZddlZddlZddlZddlmZddlmZddl m Z m Z ddl m Z ddlmZmZddlmZdd lmZerdd lmZmZmZmZmZmZmZmZdd lmZeeeefZ d Z!d dZ"ddZ#ddZ$ddZ%dddZ&ddZ'dS))absolute_importN) shlex_quote)InstallationError)console_to_strstr_to_display)subprocess_logger) HiddenTextpath_to_display)MYPY_CHECK_RUNNING) open_spinner)AnyCallableIterableListMappingOptionalTextUnion)SpinnerInterfacez(----------------------------------------cGs2g}|D]$}t|tr"||q||q|S)z& Create a CommandArgs object. ) isinstancelistextendappend)argsZ command_argsargrB/usr/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py make_commands    rcCsddd|DS)z/ Format command arguments for display.  css,|]$}t|trtt|nt|VqdS)N)rrrstr.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)rrZsecretr rrr Fsz'reveal_command_args..rr$rrrreveal_command_argsAsr'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)ZdesczCommand errored out with exit status {exit_status}: command: {command_display} cwd: {cwd_display} Complete output ({line_count} lines): {output}{divider}) exit_statuscommand_display cwd_displayZ line_countoutputZdivider)r%rr r#formatlen LOG_DIVIDER) cmd_argscwdlinesr)Zcommandr*r+r,msgrrrmake_subprocess_output_errorKs    r4FraiseTc  Cs4|dkr g}|dkrg}|r*tj} tj} n tj} tj} t| k} | oN|dk } |dkr`t|}| d|tj }|r| ||D]}| |dqz.t jt|t jt jt j||d}|jWn6tk r}z| rtd||W5d}~XYnXg}t|j}|sqJ|}||d| || r|qz |W5|jrj|jX|jo||j|k}| r|r|dn |d|r*|dkr| s| rt||||jd }t |d !|j|}t"|n:|d krt#d ||j|n|d krnt$dt%|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)stderrstdinstdoutr1envz#Error %s while executing command %s errorZdoner5)r0r1r2r)zSCommand errored out with exit status {}: {} Check the logs for full command output.warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=%sr()'rinfologgingINFOdebugDEBUGZgetEffectiveLevelr%osenvironcopyupdatepop subprocessPopenr'ZSTDOUTPIPEr7close ExceptionZcriticalrr8readlinerstriprZspinwait returncodeZfinishr4r;r-rZwarning ValueErrorreprr#)cmdZ show_stdoutr1Z on_returncodeZextra_ok_returncodesZ command_desc extra_environZ unset_environspinnerZlog_failed_cmdZlog_subprocessZ used_levelZshowing_subprocessZ use_spinnerr9nameprocexcZ all_outputlineZproc_had_errorr3Zexc_msgrrrcall_subprocessus               rZcsdfdd }|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||||dW5QRXdS)N)r1rTrU)r rZ)rSr1rTrUmessagerrrunners z+runner_with_spinner_message..runner)NNr)r\r]rr[rrunner_with_spinner_messages r^) FNr5NNNNNT)(Z __future__rr?rCrHZpip._vendor.six.movesrZpip._internal.exceptionsrZpip._internal.utils.compatrrZpip._internal.utils.loggingrZpip._internal.utils.miscrr Zpip._internal.utils.typingr Zpip._internal.utils.uir typingr r rrrrrrrrZ CommandArgsr/rr%r'r4rZr^rrrrs>      (  ,