o 7]he@s@dZddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZddlmZddlmZddlmZmZddlmZmZmZmZdd lmZmZmZmZm Z m!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/ddl0m1Z1dgZ2e3e4Z5GdddeZ6dS)z(Base Command class, and related routinesN)Values)AnyCallableListOptionalTuple) cmdoptions)CommandContextMixIn)ConfigOptionParserUpdatingDefaultsHelpFormatter)ERRORPREVIOUS_BUILD_DIR_ERROR UNKNOWN_ERRORVIRTUALENV_NOT_FOUND) BadCommand CommandErrorDiagnosticPipErrorInstallationErrorNetworkConnectionErrorPreviousBuildDirErrorUninstallationError)check_path_owner)BrokenStdoutLoggingError setup_logging)get_prognormalize_path)TempDirectoryTypeRegistry)global_tempdir_managertempdir_registry)running_under_virtualenvCommandc seZdZUdZeed<dZeed<ddedededd ffd d Zdd d Z de dd fddZ de de ede fddZde edee e effddZde ede fddZde ede fddZZS)r usageFignore_require_venvnamesummaryisolatedreturnNc 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__@/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.pyr./s*    zCommand.__init__cCsdSNr>)r9r>r>r?r8MzCommand.add_optionsoptionscCst|drJdS)zf This is a no-op so that commands by default do not do the pip version check. no_indexN)hasattr)r9rBr>r>r?handle_pip_version_checkPsz Command.handle_pip_version_checkargscCstr@)NotImplementedError)r9rBrFr>r>r?runYrAz Command.runcCs |j|Sr@)r0 parse_argsr9rFr>r>r?rI\s zCommand.parse_argscCsVz%|||WdWtS1swYWtdStwr@) main_context_mainloggingshutdownrJr>r>r?main`s  z Command.mainc s>|t|_|t||\}}|j|j|_t|j|j|j d|j r-dt j d<|j r9d|j t j d<|jrL|jsLtsLtdtt|jrdt|j|_t|jsdtd|jd|_d|jvrntd d td tfd td tfffd d }z|js||j}n|j}|||W| |S| |w)N) verbosityno_color 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_func.r'cs&tdtdtffdd }|S)NrFr'c sz|}t|ts J|WSty/}ztd|tjdddtWYd}~Sd}~wtyP}ztt |tjdddt WYd}~Sd}~wt t t tfyu}ztt |tjdddtWYd}~Sd}~wty}ztd|tjdddtWYd}~Sd}~wtytdtjdtjkrtjtjdtYStytdtjdddtYStytjd ddtYSw) Nz[present-diagnostic] %szException information:T)exc_infoz%sz ERROR: Pipe to stdout was broken)filezOperation cancelled by userz Exception:) isinstanceintrloggererrordebugr rcriticalstrr rrrrrrprintsysstderrrMDEBUG traceback print_excKeyboardInterrupt BaseExceptionr)rFstatusexc) level_numberrVr>r?exc_logging_wrappersT        zLCommand._main..intercepts_unhandled_exc..exc_logging_wrapper) functoolswrapsrrZ)rVrkrj)rVr?intercepts_unhandled_excs0z/Command._main..intercepts_unhandled_exc)! enter_contextrrrIverbosequietrPrrQlogno_inputosenviron exists_actionjoin require_venvr#rr[r^raexitr cache_dirrrwarningfeatures_enabledrrZ debug_moderHrE)r9rFrBrorHr>rnr?rLgsP          6  z Command._main)F)r'N)__name__ __module__ __qualname__r"r___annotations__r#boolr.r8rrErrZrHrrIrOrL __classcell__r>r>r<r?r +s     ")7r/rlrMlogging.configr2rurardrtypingrrrrrpip._internal.clir!pip._internal.cli.command_contextr pip._internal.cli.parserr r pip._internal.cli.status_codesr r rrpip._internal.exceptionsrrrrrrrpip._internal.utils.filesystemrpip._internal.utils.loggingrrpip._internal.utils.miscrrpip._internal.utils.temp_dirrTempDirRegistryrrpip._internal.utils.virtualenvr__all__ getLoggerrr[r r>r>r>r?s0   $