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/Gdd�de0�Z1Gdd�de1�Z2dS)z(Base Command class, and related routines�)�absolute_importN)� cmdoptions)� PackageFinder)�running_under_virtualenv)� PipSession)� BadCommand�InstallationError�UninstallationError� CommandError�PreviousBuildDirError)�logging_dictConfig)�ConfigOptionParser�UpdatingDefaultsHelpFormatter)�InstallRequirement�parse_requirements)�SUCCESS�ERROR� UNKNOWN_ERROR�VIRTUALENV_NOT_FOUND�PREVIOUS_BUILD_DIR_ERROR)� deprecation�get_prog�normalize_path)�IndentingFormatter)�pip_version_check�Commandc@s@eZdZdZdZdZd Zddd�Zddd�Zd d �Z d d �Z dS)rNF�ext://sys.stdout�ext://sys.stderrcCsr|jdt�|jft�d|j|j|d�}tf|�|_d|jj�}tj |j|�|_ t j t j |j�}|jj|�dS)Nz%s %sF)�usage�prog� formatterZadd_help_option�name� description�isolatedz %s Options)rrr!r�__doc__r �parser� capitalize�optparseZ OptionGroupZcmd_optsrZmake_option_groupZ general_groupZadd_option_group)�selfr#Z parser_kwZ optgroup_nameZgen_opts�r)�!/usr/lib/python3.6/basecommand.py�__init__)s zCommand.__init__cCs�t|jrttjj|jd��nd|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)N�http)�cache�retriesZinsecure_hosts)r,Zhttps)r� cache_dirr�os�path�joinr.� trusted_hostsZcertZverifyZ client_cert�timeout�proxyZproxies�no_inputZauthZ prompting)r(�optionsr.r4�sessionr)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�|jdkr2d�qHd�n|jrDd�nd��}|jrVd}tddd d tjd �id td d�i�d|jdd gd d�dd|jdd d�dd|jp�ddd d�d�|t t ddd|jr�dndg��d�t �fdd�d2D��d"��t j dd�d3k�rtjd$tj�|j�r(d%tjd&<|j�rBd'j|j�tjd(<|j�rft��sftjd)�t jt��z$y"|j||�}t|t��r�|SW�n�t k �r�}z tjt!|��tj"d*dd+�t#Sd}~Xn�t$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+ �r�t,|d/d� �r�|j-|dt.d0|j/�d1��}t0|�WdQRXXt1S)4N��WARNING�rZCRITICAL�DEBUG�INFOFZexclude_warningsz pip.utils.logging.MaxLevelFilter)z()�level�indentz %(message)s)z()�formatz(pip.utils.logging.ColorizedStreamHandlerr)rA�class�stream�filtersr )rArDrEr z+pip.utils.logging.BetterRotatingFileHandlerz /dev/nullT)rArD�filenameZdelayr )�console�console_errors�user_logrHrIrJ)rA�handlersc3s&|]}|d�dkrdndifVqdS)rAr@rr=r?N)r@rr))�.0r!)rAr)r*� �s zCommand.main..� pip._vendor�distlib�requests�urllib3)�versionZdisable_existing_loggersrFZ formattersrK�rootZloggers�z�Python 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.6�1Z 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:�quiet�verbose�logr �loggingr=r� log_streams�list�filter�dict�sys� version_info�warnings�warnrZPython26DeprecationWarningr6r0�environZ exists_actionr2Z require_venvr�loggerZcritical�exitrZrun� isinstance�intr �str�debugrrr rrr �KeyboardInterruptrZdisable_pip_version_check�getattrr9�minr4rr)r(r;r7Z root_levelZstatus�excr8r))rAr*�mainis�             z Command.main)rr)F)NN) �__name__� __module__� __qualname__r!rZhiddenr^r+r9r:rqr)r)r)r*r#s  $c@s"eZdZedd��Zddd�ZdS)�RequirementCommandc Cs"x6|jD],}x&t|d||||d�D]}|j|�q"WqWx&|D]}|jtj|d|j|d��q>Wx*|jD] }|jtj||j|j|d��qhWd} x8|j D].}x(t|||||d�D]}d} |j|�q�Wq�W|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 constraint�finderr7r8� 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_fileZopts�msgr)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�,) ry�format_control� index_urlsr3Zallow_all_prereleases�process_dependency_linksr8�platformZversions�abi�implementation) Z index_urlZextra_index_urlsrXrgrlr2rryr}r3Zprer)r(r7r8r�Zpython_versionsr�r�r~r)r)r*�_build_package_finder:s z(RequirementCommand._build_package_finder)NNNN)rrrsrt� staticmethodr{r�r)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 getLoggerrrrg�objectrrur)r)r)r*�s.         _