\e[c @@sddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZmZmZddlmZddlmZddlmZddlmZmZddlmZmZdd lmZm Z dd l!m"Z"dd l#m$Z$dd l%m&Z&dd l'm(Z)ddl'm*Z+ddl,m-Z.ddl/m0Z0ddl1Z1ddl2m3Z3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:ddl;m<Z<ddl=m>Z>ddl?m@Z@ddlAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLddlMmNZNddlOmPZPddlQmRZRddlSmTZTyddlUZUWneVk rdZUnXeUdk pe0ZXdddd d!d"d#d$d%d&d'g ZYejZe[Z\d(Z]d)efd*YZ^d+efd,YZ_d-efd.YZ`d/efd0YZad1ejbfd2YZcddd3Zde jed4e jfZge jed5e jfZhd6Zid7Zjd8Zkd9Zld:Zmd;Znd<Zod=Zpd>Zqd?Zrd@ZsdAZtddddBdCZudddDZvdEZwdFe&jxfdGYZydezdddBdHZ{dIZ|dJZ}dS(Ki(tabsolute_importN(trequeststsixturllib3(tCacheControlAdapter(t FileCache(t LockError(t BaseAdaptert HTTPAdapter(tAuthBaset HTTPBasicAuth(tCONTENT_CHUNK_SIZEtResponse(tCaseInsensitiveDict(tget_netrc_auth(t xmlrpc_client(tparse(trequest(tunquote(t IS_PYOPENSSL(t HashMismatchtInstallationError(twrite_delete_marker_file(tPyPI(t auto_decode(tcheck_path_owner(tlibc_ver(t indent_log( tARCHIVE_EXTENSIONStask_path_existst backup_dirtcall_subprocesstconsumet display_patht format_sizetget_installed_versiontrmtreetsplitextt unpack_file(tSETUPTOOLS_SHIM(t TempDirectory(tDownloadProgressProvider(tvcstget_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|ddcstidcS@s|dS(Ni((RD((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyREgstlibtlibcRCtdarwintmacOStsystemtreleasetcputopenssl_versiont setuptoolstsetuptools_versions9{data[installer][name]}/{data[installer][version]} {json}tdatatjsont separatorst,t:t sort_keysN(RTRU( R6t __version__tplatformtpython_versiontpython_implementationtsystpypy_version_infot releaseleveltjointstrt startswitht pip._vendorRCtdicttfiltertziptlinux_distributionRtmac_verRKt setdefaultRLtmachinetHAS_TLStssltOPENSSL_VERSIONR#tNonetformatRRtdumpstTrue(RQR\RDRCt distro_infosRHRP((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyt user_agentCsZ  -$ "%       tMultiDomainBasicAuthcB@s/eZedZdZdZdZRS(cC@s||_i|_dS(N(t promptingt passwords(tselfRs((s5/tmp/pip-install-0xiv62/pip/pip/_internal/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|st PipSessioncB@s eZdZdZdZRS(c O@s>|jdd}|jdd}|jdg}tt|j||t|jdc C@s|d krtdntj|}|r[|jdj}|dkr|r|jdrtd||fn|dkr/|jddd}|j dd}t j |}|r|jdd|jd dd}nt j |}|jdr&d|jd}n|}q[|j|}|j|j|jfSny.t|d }t|j}Wd QXWn)tk r} td t| nX||fS( s*Gets the content of a file; it may be a filename, file: URL, or http: URL. Returns (location, content). Content is unicode. :param url: File path or url. :param comes_from: Origin description of requirements. :param session: Instance of pip.download.PipSession. sAget_file_content() missing 1 required keyword argument: 'session'itfilethttps6Requirements file %s references URL %s, which is localRUs\t/t|RNs$Could not open requirements file: %s(Rlt TypeErrort _scheme_retsearchtgrouptlowerR`RRtreplacet_url_slash_drive_retmatchRzRtlstripRtraise_for_statusR|ttextRRtreadRR_( R|t comes_fromtsessionRtschemetpathRtfRR((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR+s>   *  s^(http|https|file):s /*([a-z])\|cC@sId|krtS|jdddj}|ddddgtjkS(s)Returns true if the name looks like a URLRUiiRthttpsRtftp(tFalseRRR*t all_schemes(R7R((s5/tmp/pip-install-0xiv62/pip/pip/_internal/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`tAssertionErrorRzturlsplitturllib_requestt url2pathname(R|t_R}R((s5/tmp/pip-install-0xiv62/pip/pip/_internal/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:(RRtnormpathtabspathRzturljoinRt pathname2url(RR|((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR.scC@s*t|dj}|tkr&tStS(s9Return True if `name` is a considered as an archive file.i(R%RRRoR(R7text((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR/s cC@st|}|j|dS(N(t_get_used_vcs_backendtunpack(tlinktlocationt vcs_backend((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR0s cC@s=x6tjD]+}|j|jkr ||j}|Sq WdS(N(R*tbackendsRtschemesR|(RtbackendR((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyRscC@stt|S(N(tboolR(R((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR2scC@s|jjjdS(Nsfile:(R|RR`(R((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR3scC@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((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyt is_dir_urlscO@s|S(N((titerableRR((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyt_progress_indicator sc@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(RRRtAttributeErrorRoR(t chunk_sizetchunk(R(s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyt resp_read#s     c3@s'x |D]}j||VqWdS(N(twrite(tchunksR(t content_file(s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pytwritten_chunksHs  tmaxsDownloading %s (%s)sDownloading %ssUsing cached %ssDownloading from URL %si@(tintRt ValueErrortKeyErrorRtgetattrRRtgetEffectiveLeveltloggingtINFORotshow_urlR R}RRR)tinfoR"tdebugR tcheck_against_chunksR (RRRthashest progress_bart total_lengtht cached_respt show_progressRRRtprogress_indicatorR|tdownloaded_chunks((RRs5/tmp/pip-install-0xiv62/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(R*R+R,R-(RoRRR^tfilenametexistsRR!RRRtremoveRtshutiltmoveR[texittcopyR(R.RRR4tdownload_locationRyt dest_file((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyt _copy_filens.        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'tkindRi( RlRR(t_check_download_dirRRt_download_http_urlRR&R7Rtunlink( RRt download_dirRR"R#ttemp_dirtalready_downloaded_patht from_pathR((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR4s,    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-RR RRRR$R1tcopytreeRoRRtcheck_against_pathRlR:RRR&R7(RRR=R"RR?R@R((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR1s,     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(RRRR$R[t executableRR'RRRRRR^tlistdirR&Rl(RRtsetup_pyt sdist_argsRD((s5/tmp/pip-install-0xiv62/pip/pip/_internal/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(Rt TransportRvRzR{Rt_schemet_session(Rut index_urlRt use_datetimet index_parts((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyRvs 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-TypeRQRRsHTTP error %s while getting %s(RNRlRzRROtpostRoRtverbosetparse_responseRRt HTTPErrorRtcriticalRyR( RuRthandlert request_bodyRTtpartsR|RRyR((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyRs   (RRRRRvR(((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyRLs 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. R"R#N(R2R0R3R1RlRR4R(RRR=t only_downloadRR"R#((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR5 s    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-typeRxscontent-dispositionR.twbN(R|RRRoRRRVRRWRyRRR.tcgit parse_headerR%Rtguess_extensionRRR^RR)(RRR>R"R#t target_urlRRRR.tcontent_dispositionttypetparamsRt file_pathR((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR;Js<   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( RRR^R.R/RRRCRRR<Rl(RR=R"t download_path((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyR:s  (~t __future__RR_t email.utilsRRRRRRRRXtreR1R[RaRRRtpip._vendor.cachecontrolRtpip._vendor.cachecontrol.cachesRtpip._vendor.lockfileRtpip._vendor.requests.adaptersRRtpip._vendor.requests.authR R tpip._vendor.requests.modelsR R tpip._vendor.requests.structuresR tpip._vendor.requests.utilsRtpip._vendor.six.movesRtpip._vendor.six.moves.urllibRRzRRt"pip._vendor.six.moves.urllib.parseRRtpip._vendor.urllib3.utilRR6tpip._internal.exceptionsRRtpip._internal.locationsRtpip._internal.models.indexRtpip._internal.utils.encodingRtpip._internal.utils.filesystemRtpip._internal.utils.glibcRtpip._internal.utils.loggingRtpip._internal.utils.miscRRRRR R!R"R#R$R%R&t$pip._internal.utils.setuptools_buildR'tpip._internal.utils.temp_dirR(tpip._internal.utils.uiR)tpip._internal.vcsR*Rjt ImportErrorRlRit__all__t getLoggerRRRqRrRRRtSessionRR+tcompiletIRRR,R-R.R/R0RR2R3R R R)R7R4R1RKRMRLRR5R;R:(((s5/tmp/pip-install-0xiv62/pip/pip/_internal/download.pyts            L      ES!BJ.         _ %0 $  ( ;