`8(Zc @@syddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZyddlZeZWnek reZnXddlmZddlmZddlZddlmZmZddlmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+dd l,m-Z-dd l.m/Z/dd l0m1Z1dd l2m3Z3dd l4m5Z5m6Z6ddl7m8Z8ddl9m:Z:ddl;m<Z<m=Z=ddl>m?Z?m@Z@ddlAmBZBmCZCddlDmEZEmFZFddlGmHZHddlImJZJddlKmLZLddlMmNZNddlOmPZPddlQmRZRddlSmTZTdddddd d!d"d#d$d%g ZUejVeWZXd&ZYd'eBfd(YZZd)e?fd*YZ[d+ePfd,YZ\d-e@fd.YZ]d/e<j^fd0YZ_ddd1Zae jbd2e jcZde jbd3e jcZed4Zfd5Zgd6Zhd7Zid8Zjd9Zkd:Zld;Zmd<Znd=Zod>Zpd?Zqdddd@ZrdddAZsdBZtdCeTjufdDYZvdedddEZwdFZxdGZydS(Hi(tabsolute_importN(tparse(trequest(tInstallationErrort HashMismatch(tPyPI( tsplitexttrmtreet format_sizet display_patht backup_dirtask_path_existst unpack_filetARCHIVE_EXTENSIONStconsumetcall_subprocess(t auto_decode(tcheck_path_owner(t indent_log(tSETUPTOOLS_SHIM(tlibc_ver(tDownloadProgressBartDownloadProgressSpinner(twrite_delete_marker_file(tvcs(trequeststsix(t BaseAdaptert HTTPAdapter(tAuthBaset HTTPBasicAuth(tCONTENT_CHUNK_SIZEtResponse(tget_netrc_auth(tCaseInsensitiveDict(turllib3(tCacheControlAdapter(t FileCache(t LockError(t xmlrpc_clienttget_file_contenttis_urlt url_to_patht path_to_urltis_archive_filetunpack_vcs_linktunpack_file_urlt is_vcs_urlt is_file_urltunpack_http_urlt unpack_urlc C@siidd6tjd6d6tjd6itjd6d6}|dddkrjtj|dd_stidcS@s|dS(Ni((RA((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRBcstlibtlibcR@tdarwintmacOStsystemtreleasetcpuiitopenssl_versions9{data[installer][name]}/{data[installer][version]} {json}tdatatjsont separatorst,t:t sort_keys(ii(RORP(R3t __version__tplatformtpython_versiontpython_implementationtsystpypy_version_infot releaseleveltjointstrt startswitht pip._vendorR@tdicttfiltertziptlinux_distributionRtmac_verRHt setdefaultRItmachinetHAS_TLSt version_infotssltOPENSSL_VERSIONtformatRMtdumpstTrue(RLRWRAR@t distro_infosRE((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt user_agent?sT  -$ "%    tMultiDomainBasicAuthcB@s/eZedZdZdZdZRS(cC@s||_i|_dS(N(t promptingt passwords(tselfRn((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt__init__s cC@s.tj|j}|jjddd}tj|d |f|d|_|jj|d\}}|dkr|j |j\}}n|dkr|dkrt |j}|r|nd\}}n|s|r||f|j||jddS|dfSdS(NRriiRP(NN(RytsplitR|(RpRxtuserinfo((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR}s    (t__name__t __module__RjRqRRR}(((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRms  ! "tLocalFSAdaptercB@s)eZddddddZdZRS(c C@st|j}t}d|_|j|_ytj|} Wn%tk rg} d|_| |_n}Xtj j | j dt } t j|dpd} ti| d6| jd6| d6|_t|d |_|jj|_|S( Niitusegmtis text/plains Content-TypesContent-Lengths Last-Modifiedtrb(R*RwR RtoststattOSErrorRtemailtutilst formatdatetst_mtimeRjt mimetypest guess_typeR"tst_sizetheaderstopentclose( RpRtstreamttimeouttverifytcerttproxiestpathnameRtstatstexctmodifiedt content_type((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRs$      cC@sdS(N((Rp((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRsN(RRR|RR(((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRs  t SafeFileCachecB@s2eZdZdZdZdZdZRS(sw A file based cache which is safe to use even when the target directory may not be accessible or writable. cO@sKtt|j||t|jsGtjd|jd|_ndS(NsThe directory '%s' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.(tsuperRRqRt directorytloggertwarningR|(RptargsR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRqs  cO@sQ|jdkrdSytt|j||SWntttfk rLnXdS(N(RR|RRR{R&RtIOError(RpRR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR{s cO@sQ|jdkrdSytt|j||SWntttfk rLnXdS(N(RR|RRtsetR&RR(RpRR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRs cO@sQ|jdkrdSytt|j||SWntttfk rLnXdS(N(RR|RRtdeleteR&RR(RpRR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR(s (RRt__doc__RqR{RR(((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRs   tInsecureHTTPAdaptercB@seZdZRS(cC@sd|_d|_dS(Nt CERT_NONE(t cert_reqsR|tca_certs(RptconnRwRR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt cert_verify8s (RRR(((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR6st PipSessioncB@s eZdZdZdZRS(c O@s5|jdd}|jdd}|jdg}tt|j||t|jd   *  s^(http|https|file):s /*([a-z])\|cC@sId|krtS|jdddj}|ddddgtjkS(s)Returns true if the name looks like a URLRPiiRthttpsRtftp(tFalseRRRt all_schemes(R4R((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR)s cC@sg|jdstd|tj|\}}}}}|rPd|}ntj||}|S(s( Convert a file: URL to a path. sfile:s4You can only turn file: urls into filenames (not %r)s\\(R[tAssertionErrorRuturlsplitturllib_requestt url2pathname(Rwt_RxR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR*s  cC@s=tjjtjj|}tjdtj|}|S(sh Convert a path to a file: URL. The path will be made absolute and have quoted path parts. sfile:(RRtnormpathtabspathRuturljoinRt pathname2url(RRw((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR+scC@s*t|dj}|tkr&tStS(s9Return True if `name` is a considered as an archive file.i(RRR RjR(R4text((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR,s cC@st|}|j|dS(N(t_get_used_vcs_backendtunpack(tlinktlocationt vcs_backend((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR-s cC@s=x6tjD]+}|j|jkr ||j}|Sq WdS(N(RtbackendsRtschemesRw(RtbackendR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRscC@stt|S(N(tboolR(R((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR/scC@s|jjjdS(Nsfile:(RwRR[(R((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR0scC@st|j}tjj|S(sReturn whether a file:// Link points to a directory. ``link`` must not have any other scheme but file://. Call is_file_url() first. (R*turl_without_fragmentRRtisdir(Rt link_path((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt is_dir_urlscO@s|S(N((titerableRR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt_progress_indicatorsc @sytjd}Wn tttfk r9d}nXtdt}tjt j krjt}n9|ryt}n*|d krt }n|st }nt}|j }fd}fd} t } |jtjkr|} n |j} |rM|r.tjd| t|td |j} qvtjd | tj} n)|rftjd | ntjd | tjd || | |tt} |r|j| n t| dS(Nscontent-lengthit from_cachei(ic3@sry,x%jj|dtD] }|VqWWn?tk rmx/trijj|}|saPn|Vq?WnXdS(Ntdecode_content(RRRtAttributeErrorRjR(t chunk_sizetchunk(R(s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt resp_reads     c3@s'x |D]}j||VqWdS(N(twrite(tchunksR (t content_file(s)/tmp/pip-build-0nEYGB/pip/pip/download.pytwritten_chunks:s  sDownloading %s (%s)tmaxsDownloading %ssUsing cached %ssDownloading from URL %si@(tintRt ValueErrortKeyErrorRtgetattrRRtgetEffectiveLeveltloggingtINFORjtshow_urlRRxRRtinfoRRtiterRtdebugRtcheck_against_chunksR( RRRthashest total_lengtht cached_respt show_progressRR Rtprogress_indicatorRwtdownloaded_chunks((RRs)/tmp/pip-build-0nEYGB/pip/pip/download.pyt _download_urlsL       %    cC@s,t}tjj||j}tjj|rtdt|d }|dkr^t}q|dkrt j dt|tj |q|dkrt |}t j dt|t|t j||q|dkrtjdqn|r(t j||t jd t|ndS( Ns8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)aborttitwtbtas Deleting %ssBacking up %s to %sisSaved %s(R$R%R&R'(RjRRRYtfilenametexistsR R RRRtremoveR tshutiltmoveRVtexittcopyR(R(RRR.tdownload_locationRtt dest_file((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt _copy_file`s.        c C@s|dkrtdntjdd}d}|rNt|||}n|rp|}tj|d}nt||||\}}t|||||r| rt |||n|st j |nt |dS(Ns@unpack_http_url() missing 1 required keyword argument: 'session's-unpackspip-i( R|Rttempfiletmkdtempt_check_download_dirRRt_download_http_urlR R1RtunlinkR( RRt download_dirRRttemp_dirtalready_downloaded_patht from_pathR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR1{s,    cC@st|j}t|rjtjj|r:t|ntj||dt |rft j dndS|r|j |nd}|rt|||}n|r|}n|}tj|d}t|||||r| rt|||ndS(sUnpack link into location. If download_dir is provided and link points to a file, make a copy of the link file inside download_dir. tsymlinkss*Link is a directory, ignoring download_dirNi(R*RRRRRRR+tcopytreeRjRRtcheck_against_pathR|R4RRR R1(RRR7RRR9R:R((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR.s,     c C@stjj|rt|nd}tjg}|jd|jt||jd|d|g7}tj d|t t |d|dt WdQXtjj |tj|d }tj d ||t||d dd ddS( sCopy distribution files in `link_path` to `location`. Invoked when user requests to install a local directory. E.g.: pip install . pip install ~/dev/git-repos/python-prompt-toolkit ssetup.pys-ctsdists --dist-dirsRunning setup.py sdist for %stcwdt show_stdoutNisUnpacking sdist %s into %sRR(RRRRRVt executableRRRRRRRRYtlistdirR R|(RRtsetup_pyt sdist_argsR>((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyt_copy_dist_from_dirs     "tPipXmlrpcTransportcB@s&eZdZedZedZRS(sRProvide a `xmlrpclib.Transport` implementation via a `PipSession` object. cC@s;tjj||tj|}|j|_||_dS(N(R't TransportRqRuRvRt_schemet_session(Rpt index_urlRt use_datetimet index_parts((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRqs c C@s|j||dddf}tj|}yXidd6}|jj|d|d|dt}|j||_|j |j SWn2t j k r} t jd| jj|nXdS(Nstext/xmls Content-TypeRLRRsHTTP error %s while getting %s(RHR|RuRzRItpostRjRtverbosetparse_responseRRt HTTPErrorRtcriticalRtR( RpRthandlert request_bodyRNtpartsRwRRtR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRs   (RRRRRqR(((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyRFs cC@st|rt||nVt|rAt|||d|n1|dkrYt}nt||||d||rt|ndS(svUnpack link. If link is a VCS link: if only_download, export into download_dir and ignore location else unpack into location for other types of link: - unpack into location - if download_dir, copy the file into download_dir - if only_download, mark location for deletion :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise HashUnsupported) are allowed. RN(R/R-R0R.R|RR1R(RRR7t only_downloadRR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR2s    c C@s|jjddd}y0|j|didd6dt}|jWn2tjk r}}tjd|j j |nX|j jd d }|j }|j jd } | rt j| \} } | jd p|}nt|d} | stj|} | r|| 7}qn| rd|j|jkrdtjj|jd} | rd|| 7}qdntjj||} t| d }t||||WdQX| |fS(s6Download link url into temp_dir using provided sessiont#iiRtidentitysAccept-EncodingRsHTTP error %s while getting %ss content-typeRsscontent-dispositionR(twbN(RwRR{RjRRRPRRQRtRRR(tcgit parse_headerRRtguess_extensionRRRYRR#(RRR8Rt target_urlRRRR(tcontent_dispositionttypetparamsRt file_pathR((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR5;s<   cC@stjj||j}tjj|rtjd||ry|j|Wqtk rtj d|tj |dSXn|SdS(s Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None sFile was already downloaded %ss;Previously-downloaded file %s has bad hash. Re-downloading.N( RRRYR(R)RRR=RRR6R|(RR7Rt download_path((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyR4vs  (zt __future__RRYt email.utilsRRRMRRRRStreR+RVR2RfRjRdt ImportErrorRtpip._vendor.six.moves.urllibRRuRRR3tpip.exceptionsRRt pip.modelsRt pip.utilsRRRR R R R R RRtpip.utils.encodingRtpip.utils.filesystemRtpip.utils.loggingRtpip.utils.setuptools_buildRtpip.utils.glibcRt pip.utils.uiRRt pip.locationsRtpip.vcsRR\RRtpip._vendor.requests.adaptersRRtpip._vendor.requests.authRRtpip._vendor.requests.modelsRR tpip._vendor.requests.utilsR!tpip._vendor.requests.structuresR"tpip._vendor.requests.packagesR#tpip._vendor.cachecontrolR$tpip._vendor.cachecontrol.cachesR%tpip._vendor.lockfileR&tpip._vendor.six.movesR't__all__t getLoggerRRRlRmRRRtSessionRR|R(tcompiletIRRR)R*R+R,R-RR/R0RRR#R1R1R.RERGRFR2R5R4(((s)/tmp/pip-build-0nEYGB/pip/pip/download.pyts                 F    BR!BH)         ` &0 $' ;