a *ega @sDdZddlZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z ddl mZddlmZddlmZdd lmZmZdd lmZmZmZmZdd lmZmZmZmZm Z m!Z!dd l"m#Z#dd l$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z,ddl*m-Z-m.Z.ddl/m0Z0dgZ1e2e3Z4GdddeZ5dS)z(Base Command class, and related routinesN)Values)ListOptionalTuple) reconfigure) traceback) cmdoptions)CommandContextMixIn)ConfigOptionParserUpdatingDefaultsHelpFormatter)ERRORPREVIOUS_BUILD_DIR_ERROR UNKNOWN_ERRORVIRTUALENV_NOT_FOUND) BadCommand CommandErrorDiagnosticPipErrorInstallationErrorNetworkConnectionErrorPreviousBuildDirError)check_path_owner)BrokenStdoutLoggingError setup_logging)get_prognormalize_path)TempDirectoryTypeRegistry)global_tempdir_managertempdir_registry)running_under_virtualenvCommandcseZdZUdZeed<dZeed<deeeddfdd Zdd d d Z e dd d dZ e e ee dddZe e e ee dddZe eee e efdddZe ee dddZe ee dddZZS)rusageFignore_require_venvN)namesummaryisolatedreturnc st||_||_t|jtd|td||j|d|_ d|_ |j d}t |j ||_ttj|j }|j ||dS)N F)r!prog formatteradd_help_optionr# descriptionr%z Options)super__init__r#r$r r!rr __doc__parserr capitalizeoptparse OptionGroupcmd_optsrmake_option_group general_groupadd_option_group add_options)selfr#r$r% optgroup_namegen_opts __class__H/usr/local/lib/python3.9/site-packages/pip/_internal/cli/base_command.pyr-0s*   zCommand.__init__r&cCsdSNr=)r8r=r=r>r7NszCommand.add_options)optionsr&cCst|drJdS)zf This is a no-op so that commands by default do not do the pip version check. no_indexN)hasattr)r8rAr=r=r>handle_pip_version_checkQsz Command.handle_pip_version_check)rAargsr&cCstdSr@)NotImplementedError)r8rArEr=r=r>runZsz Command.run) level_numberrArEr&c stdfdd }jr.tjdd|Sz|}t|tsDJ|WSty}z2tjd|ddidtjd dd t WYd}~Sd}~0t y}z,t t |tjd dd t WYd}~Sd}~0tttfy}z,t t |tjd dd t WYd}~Sd}~0ty`}z*t d|tjd dd t WYd}~Sd}~0tytd tjd |tjkrtjtjd t YStyt d tjd dd t YStytj ddd tYS0dS)Nr?c s*zWS0dSr@)rGrDr=rErAr8r=r> _inner_run^s   z(Command._run_wrapper.._inner_runT)Z show_localsz%sZrich)extrazException information:)exc_infoz ERROR: Pipe to stdout was broken)filezOperation cancelled by userz Exception:)intZ debug_moderich_tracebackinstall isinstancerloggererrordebugr rcriticalstrr rrrrrprintsysstderrloggingDEBUGr print_excKeyboardInterrupt BaseExceptionr)r8rHrArErJstatusexcr=rIr> _run_wrapper]sP    zCommand._run_wrapper)rEr&cCs |j|Sr@)r/ parse_argsr8rEr=r=r>rbszCommand.parse_argscCsXzH|$||WdWtS1s40YWtn t0dSr@) main_context_mainrZshutdownrcr=r=r>mains  z Command.maincCs8|t|_|t||\}}|j|j|_t|jdt |j|j|j d}t |j t t j@}|rtddt||jrdtjvrtdtt|jrdtjd<|jrd |jtjd <|jr|jststd tt|j r*t!|j |_ t"|j s*td |j d|_ |#|||S) N)no_color) verbosityrh user_log_filez/The following features are always enabled: %s. z, Z_PIP_RUNNING_IN_SUBPROCESSzAThe --python option must be placed before the pip subcommand name1 PIP_NO_INPUTr'PIP_EXISTS_ACTIONz2Could not find an activated virtualenv (required).zThe directory '%s' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.)$ enter_contextrrrbverbosequietrirrhrlogsetfeatures_enabledrZALWAYS_ENABLED_FEATURESrRwarningjoinsortedpythonosenvironrUrXexitr no_input exists_action require_venvr"rr cache_dirrrra)r8rErArHZalways_enabled_featuresr=r=r>resP            z Command._main)F)__name__ __module__ __qualname__r!rV__annotations__r"boolr-r7rrDrrNrGrarrbrgre __classcell__r=r=r;r>r,s    9 )6r.rZlogging.configr1rxrXrrtypingrrrZpip._vendor.richrrOZpip._internal.clir!pip._internal.cli.command_contextr pip._internal.cli.parserr r pip._internal.cli.status_codesr r rrpip._internal.exceptionsrrrrrrpip._internal.utils.filesystemrpip._internal.utils.loggingrrpip._internal.utils.miscrrpip._internal.utils.temp_dirrTempDirRegistryrrpip._internal.utils.virtualenvr__all__ getLoggerrrRrr=r=r=r>s0