3 Pf.@s,dZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZmZmZmZmZdd lmZdd lmZmZdd lmZmZdd lmZm Z m!Z!m"Z"m#Z#dd l$m%Z%m&Z&m'Z'ddl(m)Z)ddl*m+Z+dgZ,ej-e.Z/Gddde0Z1Gddde1Z2dS)z(Base Command class, and related routines)absolute_importN) cmdoptions) PackageFinder)running_under_virtualenv) PipSession) BadCommandInstallationErrorUninstallationError CommandErrorPreviousBuildDirError)logging_dictConfig)ConfigOptionParserUpdatingDefaultsHelpFormatter)InstallRequirementparse_requirements)SUCCESSERROR UNKNOWN_ERRORVIRTUALENV_NOT_FOUNDPREVIOUS_BUILD_DIR_ERROR) deprecationget_prognormalize_path)IndentingFormatter)pip_version_checkCommandc@s@eZdZdZdZdZd ZdddZdddZd d Z d d Z dS)rNFext://sys.stdoutext://sys.stderrcCsr|jdt|jftd|j|j|d}tf||_d|jj}tj |j||_ t j t j |j}|jj|dS)Nz%s %sF)usageprog formatterZadd_help_optionname descriptionisolatedz %s Options)rrr!r__doc__r parser capitalizeoptparseZ OptionGroupZcmd_optsrZmake_option_groupZ general_groupZadd_option_group)selfr#Z parser_kwZ optgroup_nameZgen_optsr)!/usr/lib/python3.6/basecommand.py__init__)s zCommand.__init__cCst|jrttjj|jdnd|dk r*|n|j|jd}|jrF|j|_ |j rT|j |_|j s^|rr|dk rj|n|j |_ |j r|j |j d|_ |j |j_|S)Nhttp)cacheretriesZinsecure_hosts)r,Zhttps)r cache_dirrospathjoinr. trusted_hostsZcertZverifyZ client_certtimeoutproxyZproxiesno_inputZauthZ prompting)r(optionsr.r4sessionr)r)r*_build_sessionAs    zCommand._build_sessioncCs |jj|S)N)r% parse_args)r(argsr)r)r*r:eszCommand.parse_argscs|j|\}}|jr8|jdkr"d|jdkr2dqHdn|jrDdnd}|jrVd}tddd d tjd id td did|jdd gd ddd|jdd ddd|jpddd dd|t t ddd|jrdndgdt fddd2Dd"t j ddd3krtjd$tj|jr(d%tjd&<|jrBd'j|jtjd(<|jrftsftjd)t jtz$y"|j||}t|tr|SWnt k r}z tjt!|tj"d*dd+t#Sd}~Xnt$t%t&fk r }z tjt!|tj"d*dd+t'Sd}~Xn~t(k rF}ztjd,|tj"d*dd+t'Sd}~XnDt)k rrtjd-tj"d*dd+t'Stjd.dd+t*SWd|j+ rt,|d/d r|j-|dt.d0|j/d1}t0|WdQRXXt1S)4NWARNINGrZCRITICALDEBUGINFOFZexclude_warningsz pip.utils.logging.MaxLevelFilter)z()levelindentz %(message)s)z()formatz(pip.utils.logging.ColorizedStreamHandlerr)rAclassstreamfiltersr )rArDrEr z+pip.utils.logging.BetterRotatingFileHandlerz /dev/nullT)rArDfilenameZdelayr )consoleconsole_errorsuser_logrHrIrJ)rAhandlersc3s&|]}|ddkrdndifVqdS)rAr@rr=r?N)r@rr)).0r!)rAr)r* s zCommand.main.. pip._vendordistlibrequestsurllib3)versionZdisable_existing_loggersrFZ formattersrKrootZloggerszPython 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.61Z PIP_NO_INPUT ZPIP_EXISTS_ACTIONz2Could not find an activated virtualenv (required).zException information:)exc_infoz ERROR: %szOperation cancelled by userz Exception:no_index)r.r4)rNrOrPrQ)r>rT)2r:quietverboselogr loggingr=r log_streamslistfilterdictsys version_infowarningswarnrZPython26DeprecationWarningr6r0environZ exists_actionr2Z require_venvrloggerZcriticalexitrZrun isinstanceintr strdebugrrr rrr KeyboardInterruptrZdisable_pip_version_checkgetattrr9minr4rr)r(r;r7Z root_levelZstatusexcr8r))rAr*mainis             z Command.main)rr)F)NN) __name__ __module__ __qualname__r!rZhiddenr^r+r9r:rqr)r)r)r*r#s  $c@s"eZdZeddZdddZdS)RequirementCommandc Cs"x6|jD],}x&t|d||||dD]}|j|q"WqWx&|D]}|jtj|d|j|dq>Wx*|jD] }|jtj||j|j|dqhWd} x8|j D].}x(t|||||dD]}d} |j|qWqW|j |_ |p|jp| sd|i} |j r d t | d j |j d } nd | } tj| dS) z? Marshal cmd line args into a requirement set. T)Z constraintfinderr7r8 wheel_cacheN)r#rw) default_vcsr#rwF)rvr7r8rwr!z^You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?)rV)ZlinkszLYou must give at least one requirement to %(name)s (see "pip help %(name)s"))Z constraintsrZadd_requirementrZ from_lineZ isolated_modeZ editablesZ from_editablerxZ requirementsZrequire_hashes find_linksrar2rgZwarning) Zrequirement_setr;r7rvr8r!rwrGZreqZfound_req_in_fileZoptsmsgr)r)r*populate_requirement_setsF     z+RequirementCommand.populate_requirement_setNc CsR|jg|j}|jr*tjddj|g}t|j|j||j |j |j |||||d S)zR Create a package finder appropriate to this requirement command. zIgnoring indexes: %s,) ryformat_control index_urlsr3Zallow_all_prereleasesprocess_dependency_linksr8platformZversionsabiimplementation) Z index_urlZextra_index_urlsrXrgrlr2rryr}r3Zprer)r(r7r8rZpython_versionsrrr~r)r)r*_build_package_finder:s z(RequirementCommand._build_package_finder)NNNN)rrrsrt staticmethodr{rr)r)r)r*rus 8ru)3r$Z __future__rr]r0rbr'rdZpiprZ pip.indexrZ pip.locationsrZ pip.downloadrZpip.exceptionsrrr r r Z pip.compatr Zpip.baseparserr rZpip.reqrrZpip.status_codesrrrrrZ pip.utilsrrrZpip.utils.loggingrZpip.utils.outdatedr__all__Z getLoggerrrrgobjectrrur)r)r)r*s.         _