a [fn@s<dZddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZddlmZddlmZddlmZmZddlmZmZmZmZdd lmZmZmZmZm Z m!Z!dd l"m#Z#dd l$m%Z%m&Z&dd l'm(Z(m)Z)dd l*m+Z,ddl*m-Z-m.Z.ddl/m0Z0dgZ1e2e3Z4GdddeZ5dS)z(Base Command class, and related routinesN)Values)AnyCallableListOptionalTuple) cmdoptions)CommandContextMixIn)ConfigOptionParserUpdatingDefaultsHelpFormatter)ERRORPREVIOUS_BUILD_DIR_ERROR UNKNOWN_ERRORVIRTUALENV_NOT_FOUND) BadCommand CommandErrorInstallationErrorNetworkConnectionErrorPreviousBuildDirErrorUninstallationError)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 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 formatterZadd_help_optionr# descriptionr%z Options)super__init__r#r$r r!rr __doc__parserr capitalizeoptparseZ OptionGroupZcmd_optsrZmake_option_groupZ general_groupZadd_option_group add_options)selfr#r$r%Z optgroup_nameZgen_opts __class__B/usr/lib/python3.9/site-packages/pip/_internal/cli/base_command.pyr,.s*   zCommand.__init__)r&cCsdSNr5)r2r5r5r6r1LszCommand.add_options)optionsr&cCst|drJdS)zf This is a no-op so that commands by default do not do the pip version check. Zno_indexN)hasattr)r2r8r5r5r6handle_pip_version_checkOsz Command.handle_pip_version_check)r8argsr&cCstdSr7)NotImplementedError)r2r8r;r5r5r6runXsz Command.runr;r&cCs |j|Sr7)r. parse_argsr2r;r5r5r6r?[szCommand.parse_argscCsXzH|$||WdWtS1s40YWtn t0dSr7)Z main_context_mainloggingZshutdownr@r5r5r6main_s  z Command.mainc sB|t|_|t||\}}|j|j|_t|j|j|j d|j rZdt j d<|j rrd|j t j d<|jr|jststdtt|jrt|j|_t|jstd|jd|_d|jvrtd td tftd tfd fd d }z0|js||j}n|j}|||W| |S| |0dS)N) verbosityno_colorZ user_log_file1Z PIP_NO_INPUTr'ZPIP_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.z 2020-resolverz--use-feature=2020-resolver no longer has any effect, since it is now the default dependency resolver in pip. This will become an error in pip 21.0..)run_funcr&cs$tttdfdd }|S)Nr>c sz|}t|tsJ|WSty`}z,tt|tjdddtWYd}~Sd}~0tt t t fy}z,tt|tjdddt WYd}~Sd}~0t y}z*td|tjdddt WYd}~Sd}~0ty*tdtjdtjkr"tjtjdt YStyXtdtjdddt YSty|tjdddtYS0dS) NzException information:T)exc_infoz%sz ERROR: Pipe to stdout was broken)filezOperation cancelled by userz Exception:) isinstanceintrloggercriticalstrdebugr rrrrr rrprintsysstderrrBDEBUG traceback print_excKeyboardInterrupt BaseExceptionr)r;statusexc) level_numberrGr5r6exc_logging_wrappersB    zLCommand._main..intercepts_unhandled_exc..exc_logging_wrapper) functoolswrapsrrK)rGr[rZ)rGr6intercepts_unhandled_excs+z/Command._main..intercepts_unhandled_exc)! enter_contextrrr?verbosequietrDrrElogZno_inputosenvironZ exists_actionjoinZ require_venvr"rrLrMrQexitrZ cache_dirrrZwarningZfeatures_enabledrrKZ debug_moder=r:)r2r;r8r_r=r5r^r6rAfsP           1   z Command._main)F)__name__ __module__ __qualname__r!rN__annotations__r"boolr,r1rr:rrKr=rr?rCrA __classcell__r5r5r3r6r*s     )6r-r\rBZlogging.configr0rdrQrTrtypingrrrrrZpip._internal.clirZ!pip._internal.cli.command_contextr Zpip._internal.cli.parserr r Zpip._internal.cli.status_codesr r rrZpip._internal.exceptionsrrrrrrZpip._internal.utils.filesystemrZpip._internal.utils.loggingrrZpip._internal.utils.miscrrZpip._internal.utils.temp_dirrZTempDirRegistryrrZpip._internal.utils.virtualenvr__all__Z getLoggerrhrLrr5r5r5r6s.