3 ign@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/m0Z0dgZ1ej2e3Z4GdddeZ5dS)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_virtualenvCommandcseZdZUdZedZedeeeddfdd Zdddd Ze dd d d Z e e ee d ddZ e eee e efdddZe ee dddZe ee dddZZS)rFN)namesummaryisolatedreturnc stj||_||_t|jtd|td||j|d|_ d|_ |jj d}t j |j ||_tjtj|j }|j j||jdS)N F)usageprog 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__=/tmp/pip-build-88gy_88q/pip/pip/_internal/cli/base_command.pyr,.s&   zCommand.__init__)r$cCsdS)Nr;)r7r;r;r<r6LszCommand.add_options)optionsr$cCst|d stdS)zf This is a no-op so that commands by default do not do the pip version check. no_indexN)hasattrAssertionError)r7r=r;r;r<handle_pip_version_checkOsz Command.handle_pip_version_check)r=argsr$cCstdS)N)NotImplementedError)r7r=rBr;r;r<runXsz Command.run)rBr$cCs |jj|S)N)r. parse_args)r7rBr;r;r<rE[szCommand.parse_argscCs.z|j |j|SQRXWdtjXdS)N)Z main_context_mainloggingshutdown)r7rBr;r;r<main_s z Command.mainc s8|jt|_|jt|j|\}}|j|j|_t|j|j|j d|j rZdt j d<|j rrdj|j t j d<|jr|j rtstjdtjt|jrt|j|_t|jstjd|jd|_d|jkrtjd td tftd tfd fd d }z$|js||j}n|j}|||S|j |XdS)N) verbosityno_colorZ user_log_file1 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.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$tjttdfdd }|S)N)rBr$csby|}t|tst|Stk rX}z tjt|tjdddtSd}~Xnt t t t fk r}z tjt|tjdddt Sd}~Xntk r}ztjd|tjdddt Sd}~Xntk rtdtjdtjkr tjtjdt Stk r:tjdtjdddt Stk r\tjdddtSXdS) NzException information:T)exc_infoz%sz ERROR: Pipe to stdout was broken)filezOperation cancelled by userz Exception:) isinstanceintr@rloggercriticalstrdebugr rrrrr rrprintsysstderrrGDEBUG traceback print_excKeyboardInterrupt BaseExceptionr)rBstatusexc) level_numberrOr;r<exc_logging_wrappers@   zLCommand._main..intercepts_unhandled_exc..exc_logging_wrapper) functoolswrapsrrS)rOrc)rb)rOr<intercepts_unhandled_excs+z/Command._main..intercepts_unhandled_exc)! enter_contextrrrEverbosequietrJrrKlogno_inputosenviron exists_actionjoin require_venvignore_require_venvrrTrUrYexitr cache_dirrrwarningZfeatures_enabledrrSZ debug_moderDrA)r7rBr=rfrDr;)rbr<rFfsD         /  z Command._main)F)__name__ __module__ __qualname__r&rVrqboolr,r6rrArrSrDrrErIrF __classcell__r;r;)r:r<r*s   )6r-rdrGlogging.configr0rlrYr\rZtypingrrrrrZpip._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__ getLoggerrurTrr;r;r;r<s.