Y}@sddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZyddlZdZWnek rdZYnXddlmZddlmZddlZddlmZmZddlmZdd lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)dd l*m+Z+dd l,m-Z-dd l.m/Z/ddl0m1Z1ddl2m3Z3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:m;Z;ddl<m=Z=m>Z>ddl?m@Z@mAZAddlBmCZCmDZDddlEmFZFddlGmHZHddlImJZJddlKmLZLddlMmNZNddlOmPZPddlQmRZRdddd d!d"d#d$d%d&d'g ZSejTeUZVd(d)ZWGd*d+d+e@ZXGd,d-d-e=ZYGd.d/d/eNZZGd0d1d1e>Z[Gd2d3d3e:j\Z]ddd4dZ^e j_d5e j`Zae j_d6e j`Zbd7dZcd8dZdd9d Zed:d!Zfd;d"Zgd<d=Zhd>d$Zid?d%Zjd@dAZkdBdCZldDdEZmdFdGZnddddHd&ZodddId#ZpdJdKZqGdLdMdMeRjrZsdddddNd'ZtdOdPZudQdRZvdS)S)absolute_importNTF)parse)request)InstallationError HashMismatch)PyPI) splitextrmtree format_size display_path backup_dirask_path_exists unpack_fileARCHIVE_EXTENSIONSconsumecall_subprocess) auto_decode)check_path_owner) indent_log)SETUPTOOLS_SHIM)libc_ver)DownloadProgressBarDownloadProgressSpinner)write_delete_marker_file)vcs)requestssix) BaseAdapter HTTPAdapter)AuthBase HTTPBasicAuth)CONTENT_CHUNK_SIZEResponse)get_netrc_auth)CaseInsensitiveDict)urllib3)CacheControlAdapter) FileCache) LockError) xmlrpc_clientget_file_contentis_url url_to_path path_to_urlis_archive_fileunpack_vcs_linkunpack_file_url is_vcs_url is_file_urlunpack_http_url unpack_urlc Csddddtjidtjddtjii}|dddkrdtj|ddSs zuser_agent..Jython IronPythonlinuxr)distrocSs|dS)Nr@)rCr@r@rD_szuser_agent..idcSs|dS)NrJr@)rCr@r@rDrKcsliblibcrIdarwinmacOSsystemreleasecpuopenssl_versionz9{data[installer][name]}/{data[installer][version]} {json}datajson separators,: sort_keysT)rTrU)rZr[)r7 __version__platformpython_versionpython_implementationsyspypy_version_info releaseleveljoin startswith pip._vendorrIdictfilterziplinux_distributionrmac_verrQ setdefaultrRmachineHAS_TLS version_infosslOPENSSL_VERSIONformatrXdumps)rWrbrI distro_infosrNr@r@rD user_agent?sR  ! $   "      ruc@sCeZdZdddZddZddZdd Zd S) MultiDomainBasicAuthTcCs||_i|_dS)N) prompting passwords)selfrwr@r@rD__init__s zMultiDomainBasicAuth.__init__cCs1tj|j}|jjddd}tj|dd|f|dd|_|jj|d\}}|dkr|j|j\}}|dkr|dkrt |j}|r|nd\}}|s|r||f|j||jddS|dfSdS)Nr{rJrr[)NN)rsplit)ryruserinfor@r@rDrs    z&MultiDomainBasicAuth.parse_credentialsN)__name__ __module__ __qualname__rzrrrr@r@r@rDrvs  ! "rvc@s7eZdZdddddddZddZdS)LocalFSAdapterNc Cst|j}t}d|_|j|_ytj|} Wn7tk ry} zd|_| |_WYdd} ~ XnzXtj j | j dd} t j |dpd} td| d| jd | i|_t|d |_|jj|_|S) NiusegmtTrz text/plainz Content-TypezContent-Lengthz Last-Modifiedrb)r,rr"rosstatOSErrorremailutils formatdatest_mtime mimetypes guess_typer$st_sizeheadersopenclose) ryrstreamtimeoutverifycertproxiespathnamerstatsexcmodified content_typer@r@rDrs$     zLocalFSAdapter.sendcCsdS)Nr@)ryr@r@rDrszLocalFSAdapter.close)rrrrrr@r@r@rDrs  rcs^eZdZdZfddZfddZfddZfdd ZS) SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. csHtt|j||t|jsDtjd|jd|_dS)NzThe 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.)superrrzr directoryloggerwarning)ryargsr) __class__r@rDrzs  zSafeFileCache.__init__c sR|jdkrdSytt|j||SWntttfk rMYnXdS)N)rrrrr(rIOError)ryrr)rr@rDrs zSafeFileCache.getc sR|jdkrdSytt|j||SWntttfk rMYnXdS)N)rrrsetr(rr)ryrr)rr@rDrs zSafeFileCache.setc sR|jdkrdSytt|j||SWntttfk rMYnXdS)N)rrrdeleter(rr)ryrr)rr@rDr(s zSafeFileCache.delete)rrr__doc__rzrrrr@r@)rrDrs   rc@seZdZddZdS)InsecureHTTPAdaptercCsd|_d|_dS)N CERT_NONE) cert_reqsca_certs)ryconnrrrr@r@rD cert_verify8s zInsecureHTTPAdapter.cert_verifyN)rrrrr@r@r@rDr6s rcs:eZdZdZfddZfddZS) PipSessionNc s5|jdd}|jdd}|jdg}tt|j||t|jd   '  &z^(http|https|file):z /*([a-z])\|cCsId|krdS|jdddj}|ddddgtjkS) z)Returns true if the name looks like a URLr[FrJrrhttpsrftp)rrr all_schemes)r6rr@r@rDr+s cCsd|jdstd|tj|\}}}}}|rMd|}tj||}|S)z( Convert a file: URL to a path. zfile:z4You can only turn file: urls into filenames (not %r)z\\)reAssertionErrorrurlspliturllib_request url2pathname)r_rrr@r@rDr,s  cCs=tjjtjj|}tjdtj|}|S)zh Convert a path to a file: URL. The path will be made absolute and have quoted path parts. zfile:)rrnormpathabspathrurljoinr pathname2url)rrr@r@rDr-scCs*t|dj}|tkr&dSdS)z9Return True if `name` is a considered as an archive file.rJTF)rrr)r6extr@r@rDr.s cCst|}|j|dS)N)_get_used_vcs_backendunpack)linklocation vcs_backendr@r@rDr/s cCs=x6tjD]+}|j|jkr ||j}|Sq WdS)N)rbackendsrschemesr)rbackendrr@r@rDrsrcCstt|S)N)boolr)rr@r@rDr1scCs|jjjdS)Nzfile:)rrre)rr@r@rDr2scCst|j}tjj|S)zReturn whether a file:// Link points to a directory. ``link`` must not have any other scheme but file://. Call is_file_url() first. )r,url_without_fragmentrrisdir)r link_pathr@r@rD is_dir_urlsrcOs|S)Nr@)iterablerrr@r@rD_progress_indicatorsrc sytjd}Wn!tttfk r:d}YnXtdd}tjtj krkd}n9|rzd}n*|dkrd}n|sd}nd}|j }fdd }fd d } t } |j t j kr|} n |j} |rT|r5tjd | t|td |j} q}tjd| tj} n)|rmtjd| ntjd| tjd|| | |tt} |r|j| n t| dS)Nzcontent-lengthr from_cacheF(iTc 3sjy,x%jj|ddD] }|VqWWn7tk rex"jj|}|sXP|Vq?WYnXdS)Ndecode_contentF)rrAttributeErrorr) chunk_sizechunk)rr@rD resp_reads    z _download_url..resp_readc3s'x |D]}j||VqWdS)N)write)chunksr) content_filer@rDwritten_chunks:s  z%_download_url..written_chunkszDownloading %s (%s)maxzDownloading %szUsing cached %szDownloading from URL %si@)intr ValueErrorKeyErrorrgetattrrgetEffectiveLevelloggingINFOshow_urlrrrr infor riterrdebugr!check_against_chunksr) rrrhashes total_length cached_resp show_progressr%rrprogress_indicatorrdownloaded_chunksr@)rrrD _download_urlsL       %    r0cCs#d}tjj||j}tjj|rtdt|d }|dkr^d}n|dkrtjdt|tj |nc|dkrt |}tjd t|t|t j ||n|dkrt jd |rt j||tjd t|dS)NTz8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)abortiwbaFz Deleting %szBacking up %s to %srJzSaved %s)r1r2r3r4r~)rrrdfilenameexistsr r rrremover shutilmoveraexitcopyr&)r5rrr;download_locationr} dest_filer@r@rD _copy_file`s.         r>c Cs|dkrtdtjdd}d}|rHt|||}|rj|}tj|d}nt||||\}}t|||||r| rt||||st j |t |dS)Nz@unpack_http_url() missing 1 required keyword argument: 'session'z-unpackzpip-r) rtempfilemkdtemp_check_download_dirrr_download_http_urlrr>runlinkr ) rr download_dirrr*temp_diralready_downloaded_path from_pathrr@r@rDr3{s,     cCst|j}t|rdtjj|r7t|tj||dd|r`t j ddS|rw|j |d}|rt |||}|r|}n|}t j|d}t|||||r| rt|||dS)zUnpack link into location. If download_dir is provided and link points to a file, make a copy of the link file inside download_dir. symlinksTz*Link is a directory, ignoring download_dirNr)r,r rrrr r r8copytreerr&check_against_pathrArrrr>)rrrDr*rrFrGrr@r@rDr0s,       cCstjj|rt|d}tjg}|jd|jt||jd|d|g7}tj d|t t |d|ddWd QRXtjj |tj |d }tj d ||t||d d d d d S)zCopy 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 zsetup.pyz-csdistz --dist-dirzRunning setup.py sdist for %scwd show_stdoutFNrzUnpacking sdist %s into %srr)rrr r ra executablerrrr&rrrdlistdirr)rrsetup_py sdist_argsrKr@r@rD_copy_dist_from_dirs     "rRc@s4eZdZdZdddZdddZdS)PipXmlrpcTransportzRProvide a `xmlrpclib.Transport` implementation via a `PipSession` object. FcCs;tjj||tj|}|j|_||_dS)N)r) Transportrzrrr_scheme_session)ry index_urlr use_datetime index_partsr@r@rDrzs zPipXmlrpcTransport.__init__c Cs|j||dddf}tj|}yWddi}|jj|d|d|dd}|j||_|j|jSWnDt j k r} z!t j d| j j|WYdd} ~ XnXdS)Nz Content-Typeztext/xmlrWrrTzHTTP error %s while getting %s)rUrrrVpostrverboseparse_responserr HTTPErrorrcriticalr}r) ryrhandler request_bodyr[partsrrr}rr@r@rDrs   zPipXmlrpcTransport.requestN)rrrrrzrr@r@r@rDrSs rScCst|rt||nSt|rAt|||d|n.|dkrVt}t||||d||rt|dS)avUnpack 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*N)r1r/r2r0rr3r)rrrD only_downloadrr*r@r@rDr4s    cCs|jjddd}y/|j|dddidd}|jWnDtjk r}z!tjd |jj |WYd d }~XnX|j jd d }|j }|j jd } | rt j | \} } | jdp|}t|d} | s$tj|} | r$|| 7}| rf|j|jkrftjj|jd} | rf|| 7}tjj||} t| d}t||||Wd QRX| |fS)z6Download link url into temp_dir using provided session#rJrrzAccept-EncodingidentityrTzHTTP error %s while getting %sNz content-typer|zcontent-dispositionr5wb)rrrrrr]rr^r}rrr5cgi parse_headerrrguess_extensionrrrdrr0)rrrEr* target_urlrrrr5content_dispositiontypeparamsr file_pathrr@r@rDrB;s<     rBc Cstjj||j}tjj|rtjd||ry|j|Wn3tk rtj d|tj |dSYnX|SdS)z Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None zFile was already downloaded %sz;Previously-downloaded file %s has bad hash. Re-downloading.N) rrrdr5r6rr&rJrrrC)rrDr* download_pathr@r@rDrAvs   rA)w __future__rrf email.utilsrrrXr#rrr^rer8rar?rprn ImportErrorZpip._vendor.six.moves.urllibrrrrr7pip.exceptionsrr pip.modelsr pip.utilsrr r r r r rrrrpip.utils.encodingrpip.utils.filesystemrpip.utils.loggingrpip.utils.setuptools_buildrpip.utils.glibcr pip.utils.uirr pip.locationsrpip.vcsrrfrrZpip._vendor.requests.adaptersrrZpip._vendor.requests.authrr Zpip._vendor.requests.modelsr!r"Zpip._vendor.requests.utilsr#Zpip._vendor.requests.structuresr$Zpip._vendor.requests.packagesr%pip._vendor.cachecontrolr&pip._vendor.cachecontrol.cachesr'pip._vendor.lockfiler(pip._vendor.six.movesr)__all__ getLoggerrrrurvrrrSessionrr*compileIrrr+r,r-r.r/rr1r2rrr0r>r3r0rRrTrSr4rBrAr@r@r@rDs                 F    BR!BH)         ` &0 $' ;