v]c @@saddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZmZddlmZddlmZddlmZddlmZmZddlmZmZdd lmZmZdd lm Z dd l!m"Z"dd l#m$Z$dd l%m&Z'ddl%m(Z)ddl*Z*ddl+m,Z,m-Z-ddl.m/Z/ddl0m1Z1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:ddl;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKddlLmMZMddlNmOZOddlPmQZQddlRmSZSeOr"ddlTmUZUmVZVmWZWmXZXmYZYmZZZddl[m\Z\ddl]m^Z^ddl_m`Z`ddlambZbmcZceVedededfZend d!d"d#d$d%d&d'd(d)d*d+d,g ZfejgehZiyddljZjWnEekk rdZjn/emk rZneijod-edendZjnXdWZpd2Zqd3Zrd4Zsd5efd6YZtd7efd8YZud9efd:YZvd;efd<YZwd=ejxfd>YZyddd?Zze j{d@e j|Z}e j{dAe j|Z~dBZdCZdDZdEZdFZdGZdHZdIZdJZdKZdLZddddMdNZdddOZdPe$jfdQYZdedddMdRZdSZdTZdUZdVZdS(Xi(tabsolute_importN(trequeststurllib3(tCacheControlAdapter(t FileCache(t LockError(t BaseAdaptert HTTPAdapter(tAuthBaset HTTPBasicAuth(tCONTENT_CHUNK_SIZEtResponse(tCaseInsensitiveDict(tget_netrc_auth(t xmlrpc_client(tparse(trequest(t HashMismatchtInstallationError(tPyPI(tHAS_TLStssl(t auto_decode(tcheck_path_owner(tlibc_ver(twrite_delete_marker_file(tARCHIVE_EXTENSIONStaskt ask_inputt ask_passwordtask_path_existst backup_dirtconsumet display_patht format_sizetget_installed_versiont path_to_urltremove_auth_from_urltrmtreetsplit_auth_netloc_from_urltsplitextt unpack_file(t TempDirectory(tMYPY_CHECK_RUNNING(tDownloadProgressProvider(tvcs(tOptionaltTupletDicttIOtTexttUnion(tValues(tLink(tHashes(tAuthInfotVersionControltget_file_contenttis_urlt url_to_pathR$tis_archive_filetunpack_vcs_linktunpack_file_urlt is_vcs_urlt is_file_urltunpack_http_urlt unpack_urltparse_content_dispositiontsanitize_content_filenames*Keyring is skipped due to an exception: %st BUILD_BUILDIDtBUILD_IDtCIt PIP_IS_CIcC@stdtDS(s? Return whether it looks like pip is running under CI. cs@s|]}|tjkVqdS(N(tostenviron(t.0tname((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pys ls(tanytCI_ENVIRONMENT_VARIABLES(((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt looks_like_cidsc C@s=iidd6tjd6d6tjd6itjd6d6}|dddkrjtj|ddttidcS@s|dS(Ni((R]((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR^R_tlibtlibcR\tdarwintmacOStsystemtreleasetcputopenssl_versiont setuptoolstsetuptools_versiontcitPIP_USER_AGENT_USER_DATAt user_datas9{data[installer][name]}/{data[installer][version]} {json}tdatatjsont separatorst,t:t sort_keysN(RqRr($RPt __version__tplatformtpython_versiontpython_implementationtsystpypy_version_infot releaseleveltjointstrt startswitht pip._vendorR\tdicttfiltertziptlinux_distributionRtmac_verRet setdefaultRftmachineRRtOPENSSL_VERSIONR#tNoneROtTrueRIRJtgettformatRotdumps(RnRyR]R\t distro_infosRbRjRm((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt user_agentosb  -$ "%         cC@s| st rdSyy tj}Wntk r5n@Xtjd||||}|dk rq|j|jfSdS|rtjd|tj||}|r||fSnWn)t k r}tj dt |nXdS(s3Return the tuple auth for a given url from keyring.s'Getting credentials from keyring for %ss$Getting password from keyring for %ss*Keyring is skipped due to an exception: %sN( tkeyringRtget_credentialtAttributeErrortloggertdebugtusernametpasswordt get_passwordt ExceptiontwarningR|(turlRRtcredRtexc((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt_get_keyring_auths(    tMultiDomainBasicAuthcB@sneZed dZdZeedZdZdZdZ dZ dZ dZ d Z RS( cC@s(||_||_i|_d|_dS(N(t promptingt index_urlst passwordsRt_credentials_to_save(tselfRR((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt__init__s   cC@sY| s|j rdSx=|jD]2}t|jdd}|j|r|SqWdS(sReturn the original index URL matching the requested URL. Cached or dynamically generated credentials may work against the original index URL rather than just the netloc. The provided url should have had its username and password removed already. If the original index url had credentials then they will be included in the return value. Returns None if no matching index was found, or if --no-index was specified by the user. t/N(RRR%trstripR}(RRtutprefix((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt_get_index_urls cC@sdt|\}}}|\}}|dk rM|dk rMtjd||S|j|} | rt| } | r| \} } } tjd| qn| r| ddk r| \}}|dk r|dk rtjd|| Sn|rt|} | rtjd|| Sn|rZt| |p:t||}|rZtjd||Sn||fS(s2Find and return credentials for the specified URL.sFound credentials in url for %ssFound index url %sis%Found credentials in index url for %ss!Found credentials in netrc for %ss#Found credentials in keyring for %sN(R'RRRRR R(Rt original_urlt allow_netrct allow_keyringRtnetlocturl_user_passwordRRt index_urlt index_infot_tindex_url_user_passwordt netrc_authtkr_auth((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt_get_new_credentialss:    cC@st|\}}}|jj|d\}}|dkr`|dkr`|j|\}}n|dk sx|dk r|pd}|pd}||f|j|   *  s^(http|https|file):s /*([a-z])\|cC@sId|krtS|jdddj}|ddddgtjkS(s)Returns true if the name looks like a URLRriiRthttpsRtftp(RRRR-t all_schemes(RLR#((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR:s cC@s|jdstd|tj|\}}}}}| sP|dkrYd}n,tjdkrud|}ntd|tj||}|S(s( Convert a file: URL to a path. sfile:s4You can only turn file: urls into filenames (not %r)t localhostR_twin32s\\s:non-local file URIs are not supported on this platform: %r( R}RRturlsplitRxRut ValueErrorturllib_requestt url2pathname(RRRR$((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR;s    cC@s*t|dj}|tkr&tStS(s9Return True if `name` is a considered as an archive file.i(R(RRRR(RLtext((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR<s cC@s&t|}|j|d|jdS(NR(t_get_used_vcs_backendtunpackR(tlinktlocationt vcs_backend((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR=s cC@s.x'tjD]}|j|jkr |Sq WdS(s1 Return a VersionControl object or None. N(R-tbackendsR#tschemesR(R2R4((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR0scC@stt|S(N(tboolR0(R2((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR?scC@s|jjjdS(Nsfile:(RRR}(R2((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR@scC@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_fragmentRIR$tisdir(R2t link_path((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt is_dir_urlscO@s|S(N((titerableRR((s5/tmp/pip-install-vZZv26/pip/pip/_internal/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} |rAt|d|} |r.tjd | t|qjtjd | n)|rZtjd | 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(RRRRRR (t chunk_sizetchunk(R(s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt resp_reads     c3@s'x |D]}j||VqWdS(N(twrite(tchunksRA(t content_file(s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pytwritten_chunks<s  tmaxsDownloading %s (%s)sDownloading %ssUsing cached %ssDownloading from URL %si@(tintRR,tKeyErrorRtgetattrRRtgetEffectiveLeveltloggingtINFORtshow_urlR=RRR8R,RR"RR tcheck_against_chunksR (RR2REthashest progress_bart total_lengtht cached_respt show_progressRNRBRFtprogress_indicatorRtdownloaded_chunks((RERs5/tmp/pip-install-vZZv26/pip/pip/_internal/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(RXRYRZR[(RRIR$R{tfilenametexistsRR!RRRtremoveRtshutiltmoveRxtexittcopyR(R\R3R2Rbtdownload_locationRt dest_file((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyt _copy_filebs.        tonc C@s|dkrtdntdd}d}|rNt|||}n|rp|}tj|d} n!t|||j||\}} t||| ||r| rt |||n|st j |nWdQXdS(Ns@unpack_http_url() missing 1 required keyword argument: 'session'tkindR1i( RRR*t_check_download_dirRRt_download_http_urlR$R)ReRItunlink( R2R3t download_dirR"RPRQttemp_dirtalready_downloaded_patht from_pathR((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRA}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;R8R;RIR$R9R&R_tcopytreeRRRtcheck_against_pathRRhRRR)Re(R2R3RkRPR:RmRnR((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyR>s,      tPipXmlrpcTransportcB@s&eZdZedZedZRS(sRProvide a `xmlrpclib.Transport` implementation via a `PipSession` object. cC@s;tjj||tj|}|j|_||_dS(N(Rt TransportRRRR#t_schemet_session(RRR"t use_datetimet index_parts((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRs 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-TypeRnRRsHTTP error %s while getting %s(RtRRt urlunparseRutpostRRtverbosetparse_responseRRt HTTPErrorRtcriticalRR( RRthandlert request_bodyRztpartsRRRR((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRs   (RRRRRR(((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRrs c C@st|rt||n\t|rAt|||d|n7|dkrYt}nt||||d|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. RPRQN(R?R=R@R>RRRAR(R2R3Rkt only_downloadR"RPRQ((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRBs    cC@stjj|S(sJ Sanitize the "filename" value from a Content-Disposition header. (RIR$tbasename(R\((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRD.scC@sCtj|\}}|jd}|r9t|}n|pB|S(s Parse the "filename" value from a Content-Disposition header, and return the default filename if the result is empty. R\(tcgit parse_headerRRD(tcontent_dispositiontdefault_filenamet_typetparamsR\((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRC6s c C@s|jjddd}y0|j|didd6dt}|jWn2tjk r}}tjd|j j |nX|j jd d }|j } |j jd } | rt | | } nt| d} | stj|} | r| | 7} qn| rI|j|jkrItjj|jd} | rI| | 7} qIntjj|| } t| d } t||| ||Wd QX| |fS(s6Download link url into temp_dir using provided sessiont#iiRtidentitysAccept-EncodingRsHTTP error %s while getting %ss content-typeR_scontent-dispositiontwbN(RRRRRRR|RR}RRRR\RCR(Rtguess_extensionRIR$R{RRW(R2R"RlRPRQt target_urlRRRR\RR/t file_pathRE((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRiEs:    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( RIR$R{R\R]RRRqRRRjR(R2RkRPt download_path((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyRhs  (RERFRGRH(t __future__RRt email.utilsRRoRLRRIRutreR_RxR~RRtpip._vendor.cachecontrolRtpip._vendor.cachecontrol.cachesRtpip._vendor.lockfileRtpip._vendor.requests.adaptersRRtpip._vendor.requests.authRR tpip._vendor.requests.modelsR R tpip._vendor.requests.structuresR tpip._vendor.requests.utilsR tpip._vendor.six.movesRtpip._vendor.six.moves.urllibRRRR-RPtpip._internal.exceptionsRRtpip._internal.models.indexRtpip._internal.utils.compatRRtpip._internal.utils.encodingRtpip._internal.utils.filesystemRtpip._internal.utils.glibcRt pip._internal.utils.marker_filesRtpip._internal.utils.miscRRRRRRR R!R"R#R$R%R&R'R(R)tpip._internal.utils.temp_dirR*tpip._internal.utils.typingR+tpip._internal.utils.uiR,tpip._internal.vcsR-ttypingR.R/R0R1R2R3toptparseR4tpip._internal.models.linkR5tpip._internal.utils.hashesR6t pip._internal.vcs.versioncontrolR7R8R|t Credentialst__all__t getLoggerRRRt ImportErrorRRRRRNRORRRRRRtSessionRR9tcompiletIRRR:R;R<R=R0R?R@R;R=RWReRAR>RsRrRRBRDRCRiRh(((s5/tmp/pip-install-vZZv26/pip/pip/_internal/download.pyts           j.         O !BQ/      f  * 2  *   ?