U ÀÒ.e·&ã @sddlmZddlZddlZddlZddlmZddlmZddl m Z m Z ddl m Z ddlmZmZddlmZdd lmZerÈdd lmZmZmZmZmZmZmZmZdd lmZeeeefZ d Z!d d„Z"dd„Z#dd„Z$dd„Z%ddd„Z&dd„Z'dS)é)Úabsolute_importN)Ú shlex_quote)ÚInstallationError)Úconsole_to_strÚstr_to_display)Úsubprocess_logger)Ú HiddenTextÚpath_to_display)ÚMYPY_CHECK_RUNNING)Ú open_spinner)ÚAnyÚCallableÚIterableÚListÚMappingÚOptionalÚTextÚUnion)ÚSpinnerInterfacez(----------------------------------------cGs2g}|D]$}t|tƒr"| |¡q| |¡q|S)z& Create a CommandArgs object. )Ú isinstanceÚlistÚextendÚappend)ÚargsZ command_argsÚarg©rúB/usr/lib/python3.8/site-packages/pip/_internal/utils/subprocess.pyÚ make_commands    rcCsd dd„|Dƒ¡S)z/ Format command arguments for display. ú css,|]$}t|tƒrtt|ƒƒnt|ƒVqdS)N)rrrÚstr©Ú.0rrrrÚ ;sÿz&format_command_args..)Újoin©rrrrÚformat_command_args1s þr%cCsdd„|DƒS)z= Return the arguments in their raw, unredacted form. cSs g|]}t|tƒr|jn|‘qSr)rrZsecretr rrrÚ Fsz'reveal_command_args..rr$rrrÚreveal_command_argsAsÿr'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)ZdescÚzŸCommand errored out with exit status {exit_status}: command: {command_display} cwd: {cwd_display} Complete output ({line_count} lines): {output}{divider})Ú exit_statusÚcommand_displayÚ cwd_displayZ line_countÚoutputZdivider)r%rr r#ÚformatÚlenÚ LOG_DIVIDER) Úcmd_argsÚcwdÚlinesr)Zcommandr*r+r,ÚmsgrrrÚmake_subprocess_output_errorKs   ü òr4FÚraiseTc  Cs4|dkr g}|dkrg}|r*tj} tj} n tj} tj} t ¡| k} | oN|dk } |dkr`t|ƒ}| d|ƒtj   ¡}|r‚|  |¡|D]}|  |d¡q†z.t jt|ƒt jt jt j||d�}|j ¡Wn6tk rü}z| rêt d||¡‚W5d}~XYnXg}t|j ¡ƒ}|�s�qJ| ¡}| |d¡| |ƒ| �r| ¡�qz | ¡W5|j�rj|j ¡X|j�o||j|k}| �r |�r–| d¡n | d¡|�r*|dk�rð| �sØ| �rØt||||jd �}t  |¡d  !|j|¡}t"|ƒ‚n:|d k�rt #d ||j|¡n|d k�rnt$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)ÚstderrÚstdinÚstdoutr1Úenvz#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 %sÚignorezInvalid value: on_returncode=%sr()'rÚinfoÚloggingÚINFOÚdebugÚDEBUGZgetEffectiveLevelr%ÚosÚenvironÚcopyÚupdateÚpopÚ subprocessÚPopenr'ZSTDOUTÚPIPEr7ÚcloseÚ ExceptionZcriticalrr8ÚreadlineÚrstriprZspinÚwaitÚ returncodeZfinishr4r;r-rZwarningÚ ValueErrorÚreprr#)ÚcmdZ show_stdoutr1Z on_returncodeZextra_ok_returncodesZ command_descÚ extra_environZ unset_environÚspinnerZlog_failed_cmdZlog_subprocessZ used_levelZshowing_subprocessZ use_spinnerr9ÚnameÚprocÚexcZ all_outputÚlineZproc_had_errorr3Zexc_msgrrrÚcall_subprocessusª    üÿ   ÿ    ü ÿý  þ ÿrZcsd‡fdd„ }|S)zÜProvide 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||||d�W5QRXdS)N)r1rTrU)r rZ)rSr1rTrU©ÚmessagerrÚrunners üz+runner_with_spinner_message..runner)NNr)r\r]rr[rÚrunner_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^rrrrÚs>      (  ,ö