abc@sddlmZddlZddlZddlZddlZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlmZmZddlmZmZmZmZmZddlmZddlm Z m!Z!dd l"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+dd l,m-Z-m.Z.e j/e0Z1e2a3e4ed rd Z5n9ej6j7d rdZ5nej6dkrdZ5ndZ5ej8dZ9e9 rdej:d Z9nde9Z;e5e9Z<ej"j=j>ddj>ddZ?ej8dZ@e@oze@j7dre@j>ddZ@ndZAeAZ@[AejBdejCejDBZEejBdejCejDBZFejBdZGejBdZHd ZId!ZJe jKd"kr$d#ZLn d$ZLd%eMfd&YZNeNZOd'eMfd(YZPd)ZQeQZR[Qe2d*ZSdS(+i(tunicode_literalsN(tmessage_from_filei(t __version__tDistlibException(t sysconfigtZipFiletfsdecodet text_typetfilter(tInstalledDistribution(tMetadatatMETADATA_FILENAME( t FileOperatort convert_patht CSVReadert CSVWritertCachetcached_propertytget_cache_baset read_exportsttempdir(tNormalizedVersiontUnsupportedVersionErrorupypy_version_infouppujavaujyucliuipucpupy_version_nodotu%s%siupyu-u_u.uSOABIucpython-cCs|dtg}tjdr+|jdntjdrJ|jdntjddkro|jdnd j|S( NucpuPy_DEBUGudu WITH_PYMALLOCumuPy_UNICODE_SIZEiuuu(t VER_SUFFIXRtget_config_vartappendtjoin(tparts((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt _derive_abi;s uz (?P[^-]+) -(?P\d+[^-]*) (-(?P\d+[^-]*))? -(?P\w+\d+(\.\w+\d+)*) -(?P\w+) -(?P\w+(\.\w+)*) \.whl$ u7 (?P[^-]+) -(?P\d+[^-]*) (-(?P\d+[^-]*))?$ s \s*#![^\r\n]*s^(\s*#!("[^"]+"|\S+))\s+(.*)$s#!pythons #!pythonwu/cCs|S(N((to((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt]tcCs|jtjdS(Nu/(treplacetostsep(R((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyR_RtMountercBs8eZdZdZdZddZdZRS(cCsi|_i|_dS(N(t impure_wheelstlibs(tself((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt__init__cs cCs!||j|<|jj|dS(N(R$R%tupdate(R&tpathnamet extensions((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytaddgs cCsI|jj|}x0|D](\}}||jkr|j|=qqWdS(N(R$tpopR%(R&R)R*tktv((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytremovekscCs"||jkr|}nd}|S(N(R%tNone(R&tfullnametpathtresult((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt find_moduleqs cCs|tjkrtj|}nx||jkrAtd|ntj||j|}||_|jdd}t|dkr|d|_ n|S(Nuunable to find extension for %su.ii( tsystmodulesR%t ImportErrortimpt load_dynamict __loader__trsplittlent __package__(R&R1R3R((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt load_modulexs N(t__name__t __module__R'R+R/R0R4R>(((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyR#bs     tWheelcBseZdZdZdZdeedZedZ edZ edZ e dZ dZe d Zd Zdd Zd Zd ZdZdddZdZdZdZdZdZedZdZdZddZRS(u@ Class to build and install from Wheel files (PEP 427). iusha256cCs||_||_d|_tg|_dg|_dg|_tj|_ |dkr{d|_ d|_ |j |_nEtj|}|r|jd}|d|_ |djdd |_ |d |_|j |_ntjj|\}}tj|}|s!td |n|r?tjj||_ n||_|jd}|d|_ |d|_ |d |_|d jd |_|djd |_|djd |_dS(uB Initialise an instance using a (valid) filename. uunoneuanyudummyu0.1unmuvnu_u-ubnuInvalid name or filename: %rupyu.ubiuarN(tsignt should_verifytbuildvertPYVERtpyvertabitarchR!tgetcwdtdirnameR0tnametversiontfilenamet _filenametNAME_VERSION_REtmatcht groupdictR R2tsplitt FILENAME_RERtabspath(R&RMRBtverifytmtinfoRJ((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyR'sB                cCs|jrd|j}nd}dj|j}dj|j}dj|j}|jjdd}d|j|||||fS(uJ Build and return a filename from the various components. u-uu.u_u%s-%s%s-%s-%s-%s.whl(RDRRFRGRHRLR RK(R&RDRFRGRHRL((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyRMs cCs+tjj|j|j}tjj|S(N(R!R2RRJRMtisfile(R&R2((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytexistssccsNxG|jD]<}x3|jD](}x|jD]}|||fVq*WqWq WdS(N(RFRGRH(R&RFRGRH((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyttagssc Cs8tjj|j|j}d|j|jf}d|}tjd}t |d}|j |}|dj dd}t g|D]}t |^q} | d krd} nt} yItj|| } |j| "} || } td | }WdQXWn!tk r-td | nXWdQX|S( Nu%s-%su %s.dist-infouutf-8uru Wheel-Versionu.iuMETADATAtfileobju$Invalid wheel, because %s is missing(ii(R!R2RRJRMRKRLtcodecst getreaderRtget_wheel_metadataRRttupletintR t posixpathtopenR tKeyErrort ValueError(R&R)tname_vertinfo_dirtwrappertzftwheel_metadatatwvtit file_versiontfntmetadata_filenametbftwfR3((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytmetadatas( %    cCsud|j|jf}d|}tj|d}|j|(}tjd|}t|}WdQXt|S(Nu%s-%su %s.dist-infouWHEELuutf-8( RKRLRaRRbR\R]Rtdict(R&RhReRfRnRoRptmessage((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyR^s cCsFtjj|j|j}t|d}|j|}WdQX|S(Nur(R!R2RRJRMRR^(R&R)RhR3((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyRWsc Cstj|}|r|j}|| ||}}d|jkrQt}nt}tj|}|rd|jd}nd}||}||}ns|jd}|jd} |dks|| krd} n&|||d!d krd } nd} t| |}|S( Ntpythonwt iRs s iis ( t SHEBANG_RERPtendtlowertSHEBANG_PYTHONWtSHEBANG_PYTHONtSHEBANG_DETAIL_REtgroupstfind( R&tdataRVRwtshebangtdata_after_shebangtshebang_pythontargstcrtlftterm((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytprocess_shebangs,      cCs|dkr|j}nytt|}Wn!tk rNtd|nX||j}tj|j dj d}||fS(NuUnsupported hash algorithm: %rt=uascii( R0t hash_kindtgetattrthashlibtAttributeErrorRtdigesttbase64turlsafe_b64encodetrstriptdecode(R&R~RthasherR3((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytget_hashs   !cCs~t|}ttjj||}|j|ddf|jt|%}x|D]}|j|q]WWdQXdS(Nu( tlisttto_posixR!R2trelpathRtsortRtwriterow(R&trecordst record_pathtbasetptwritertrow((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt write_record's   cCsg}|\}}tt|j}xs|D]k\}} t| d} | j} WdQXd|j| } tjj| } |j || | fq+Wtjj |d} |j || |t tjj |d}|j || fdS(Nurbu%s=%suRECORD( RRRRbtreadRR!R2tgetsizeRRRR(R&RWtlibdirt archive_pathsRtdistinfoRfRtapRtfR~Rtsize((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt write_records0s c Cs\t|dtjA}x7|D]/\}}tjd|||j||qWWdQXdS(NuwuWrote %s to %s in wheel(Rtzipfilet ZIP_DEFLATEDtloggertdebugtwrite(R&R)RRhRR((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt build_zip@sc! s|dkri}nttfdd$d}|dkrgd}tg}tg}tg}n!d}tg}dg}dg}|jd ||_|jd ||_ |jd ||_ |} d |j |j f} d | } d| } g} xKd%D]C}|kr qn|}t jj|rx t j|D]\}}}x|D]}tt jj||}t jj||}tt jj| ||}| j||f|dkrb|jd rbt|d}|j}WdQX|j|}t|d}|j|WdQXqbqbWqLWqqW| }d}xt j|D]\}}}||krxUt|D]G\}}t|}|jdrt jj||}||=PqqW|stdnxl|D]d}t|jd&rqnt jj||}tt jj||}| j||fqWqkWt j|}xf|D]^}|d'kr|tt jj||}tt jj| |}| j||fq|q|Wd|p|jdtd |g}x4|j D])\}}}|jd!|||fq Wt jj|d}t|d"}|jd#j|WdQXtt jj| d}| j||f|j!|| f| | t jj|j"|j#} |j$| | | S((u Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel. cs |kS(N((R(tpaths(s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyRNRupurelibuplatlibiufalseutrueunoneuanyupyveruabiuarchu%s-%su%s.datau %s.dist-infoudatauheadersuscriptsu.exeurbNuwbu .dist-infou(.dist-info directory expected, not foundu.pycu.pyouRECORDu INSTALLERuSHAREDuWHEELuWheel-Version: %d.%duGenerator: distlib %suRoot-Is-Purelib: %su Tag: %s-%s-%suwu (upurelibuplatlib(udatauheadersuscripts(u.pycu.pyo(uRECORDu INSTALLERuSHAREDuWHEEL(%R0RRtIMPVERtABItARCHREtgetRFRGRHRKRLR!R2tisdirtwalkRRRRRtendswithRbRRRt enumeratetAssertionErrortlistdirt wheel_versionRRZRRJRMR(!R&RRZRtlibkeytis_puret default_pyvert default_abit default_archRRetdata_dirRfRtkeyR2troottdirstfilesRmRtrpRRR~RRktdnRiRFRGRHR)((Rs=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytbuildFs  "              %      cCKs |j}|jd}|jdt}tjj|j|j}d|j|j f}d|} d|} t j| t } t j| d} t j| d} t j d}t|d }|j| }||}t|}Wd QX|d jd d }tg|D]}t|^q}||jkrY|rY||j|n|ddkrv|d}n |d}i}|j| D}td|,}x"|D]}|d}||||jd.}6|6r|6jd/}6nWd QXWnt1k rt+j2d0nX|6r|6jd1i}>|6jd2i}?|>s|?r|jdd}@tjj?|@st@d3n|@|_xF|>jAD]8\}:}<d4|:|<f}A|j4|A}4|j5|4q(W|?ritd(6}BxL|?jAD];\}:}<d4|:|<f}A|j4|A|B}4|j5|4qWqqntjj|| }tB|}5tC|}|d=|d=||d5<|5jD||}|r9 |!j/|n|5jE|!|d6||5SWn+t1k r t+jFd7|jGnXWd tHjI|"XWd QXd S(9u Install a wheel to the specified paths. If kwarg ``warner`` is specified, it should be a callable, which will be called with two tuples indicating the wheel version of this software and the wheel version in the file, if there is a discrepancy in the versions. This can be used to issue any warnings to raise any exceptions. If kwarg ``lib_only`` is True, only the purelib/platlib files are installed, and the headers, scripts, data and dist-info metadata are not written. The return value is a :class:`InstalledDistribution` instance unless ``options.lib_only`` is True, in which case the return value is ``None``. uwarnerulib_onlyu%s-%su%s.datau %s.dist-infouWHEELuRECORDuutf-8urNu Wheel-Versionu.iuRoot-Is-Purelibutrueupurelibuplatlibtstreamiuuscriptstdry_runu /RECORD.jwsiusize mismatch for %su=udigest mismatch for %sulib_only: skipping %su.exeu/urbudigest mismatch on write for %su.pyuByte-compilation failedtexc_infoulib_only: returning Noneu1.0uentry_points.txtuconsoleuguiu %s_scriptsuwrap_%su%s:%su %suAUnable to read legacy script metadata, so cannot generate scriptsu extensionsupython.commandsu8Unable to read JSON metadata, so cannot generate scriptsu wrap_consoleuwrap_guiuValid script path not specifiedu%s = %sulibuprefixuinstallation failed.(uconsoleugui(JRRtFalseR!R2RRJRMRKRLRaR R\R]RRbRRRR_R`RRR tTruetrecordR5tdont_write_bytecodettempfiletmkdtempt source_dirR0t target_dirtinfolistt isinstanceRRRtstrt file_sizeRRRt startswithRRR t copy_streamRt byte_compilet Exceptiontwarningtbasenametmaketset_executable_modetextendRWRtvaluestprefixtsuffixtflagstjsontloadRRdtitemsR Rrtwrite_shared_locationstwrite_installed_filest exceptiontrollbacktshutiltrmtree(CR&RtmakertkwargsRtwarnertlib_onlyR)ReRRft metadata_nametwheel_metadata_namet record_nameRgRhtbwfRpRsRjRkRlRRRotreaderRRtdata_pfxtinfo_pfxt script_pfxtfileoptbctoutfilestworkdirtzinfotarcnamet u_arcnametkindtvalueR~t_Rt is_scripttwhereRtoutfilet newdigesttpycRmtworknameRt filenamestdisttcommandsteptepdataRR-tdR.tstconsole_scriptst gui_scriptst script_dirtscripttoptions((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytinstallsD    %            #   "                            cCsGtdkrCtjjttdtjd }t |antS(Nu dylib-cachei( tcacheR0R!R2RRRR5RLR(R&R((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt_get_dylib_caches  c Cstjj|j|j}d|j|jf}d|}tj|d}tj d}g}t |dw}y\|j |G}||} t j | } |j} | j|} tjj| j| } tjj| stj| nx| jD]\}}tjj| t|}tjj|sHt}nQtj|j}tjj|}|j|}tj|j}||k}|r|j|| n|j||fqWWdQXWntk rnXWdQX|S(Nu%s-%su %s.dist-infou EXTENSIONSuutf-8ur( R!R2RRJRMRKRLRaR\R]RRbRRRt prefix_to_dirRRtmakedirsRR RYRtstattst_mtimetdatetimet fromtimestamptgetinfot date_timetextractRRc(R&R)ReRfRRgR3RhRoRpR*RRt cache_baseRKRtdestRt file_timeRWt wheel_time((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt_get_extensionss>     !  cCs t|S(uM Determine if a wheel is compatible with the running system. (t is_compatible(R&((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyR%scCstS(uP Determine if a wheel is asserted as mountable by its metadata. (R(R&((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyt is_mountablescCs tjjtjj|j|j}|jsLd|}t|n|jsqd|}t|n|t jkrt j d|ns|rt jj |nt jj d||j}|rtt jkrt jj tntj||ndS(Nu)Wheel %s not compatible with this Python.u$Wheel %s is marked as not mountable.u%s already in pathi(R!R2RTRRJRMR%RR&R5RRRtinsertR$t_hookt meta_pathR+(R&RR)tmsgR*((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytmounts"'     cCstjjtjj|j|j}|tjkrItjd|n]tjj ||t j krxt j |nt j st tj krtj j t qndS(Nu%s not in path( R!R2RTRRJRMR5RRR/R(R$R)(R&R)((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytunmounts' cCstjj|j|j}d|j|jf}d|}d|}tj|t}tj|d}tj|d}t j d}t |d } | j |} || } t | } WdQX| djd d } tg| D]}t|^q}i}| j |D}td |,}x"|D]}|d }|||Fsu0Cannot update non-compliant (PEP-440) version %rR2tlegacyuVersion updated from %r to %r(R0RR}RRR`RRRRR RLRR R( RLR2tupdatedR.RkRRtmdR0((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytupdate_version;s(   0 !     u%s-%su %s.dist-infouRECORDuruutf-8u..uinvalid entry in wheel: %rNRu.whlRu wheel-update-tdiruNot a directory: %r(R!R2RRJRMRKRLRaRRRRRRRRR R0RtmkstemptcloseRRRRRRtcopyfile(R&tmodifiertdest_dirRR.R3R)ReRfRRRhR-RRRR2toriginal_versionRtmodifiedtcurrent_versiontfdtnewpathRRRW((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyR( sX           (iiN(R?R@t__doc__RRR0RR'tpropertyRMRYRZRRqR^RWRRRRRRRRR$R%R&R+R,RUR((((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyRAs2)    h "    6cCstg}td}xGttjddddD](}|jdj|t|gq1Wg}xLtjD]>\}}}|j drp|j|j dddqpqpW|j t dkr|j dt n|jdg}tg}tjd kr=tjd t}|r=|j\} }}} t|}| g} | dkrg| jd n| dkr| jdn| dkr| jdn| dkr| jdn| dkr| jdnx`|dkr6x@| D]8} d| ||| f} | tkr|j| qqW|d8}qWq=nxH|D]@}x7|D]/} |jdjt|df|| fqQWqDWxwt|D]i\}}|jdjt|fddf|dkr|jdjt|dfddfqqWxwt|D]i\}}|jdjd|fddf|dkr|jdjd|dfddfqqWt|S(uG Return (pyver, abi, arch) tuples compatible with this Python. iiiuu.abiu.iunoneudarwinu(\w+)_(\d+)_(\d+)_(\w+)$ui386uppcufatux86_64ufat3uppc64ufat64uintelu universalu %s_%s_%s_%suanyupy(ui386uppc(ui386uppcux86_64(uppc64ux86_64(ui386ux86_64(ui386ux86_64uinteluppcuppc64(RtrangeR5t version_infoRRRR8t get_suffixesRRRRRR'RtplatformtreRPR|R`t IMP_PREFIXRtset(tversionstmajortminortabisRRR3tarchesRVRKRHtmatchesRPRRGRkRL((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pytcompatible_tagss`  $&$               1% 0% 0cCst|tst|}nt}|dkr9t}nxN|D]F\}}}||jkr@||jkr@||jkr@t}Pq@q@W|S(N( RRARR0tCOMPATIBLE_TAGSRFRGRHR(twheelRZR3tverRGRH((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyR%s  -(Tt __future__RRR\Rtdistutils.utilt distutilstemailRRR8RtloggingR!RaRERR5RRRRRtcompatRRRRRtdatabaseR RqR R tutilR R RRRRRRRRLRRt getLoggerR?RR0RthasattrRFRDRRRRBRERt get_platformR RRRtcompilet IGNORECASEtVERBOSERSRORvR{RzRyR"RtobjectR#R(RARNROR%(((s=/usr/lib/python2.7/site-packages/pip/_vendor/distlib/wheel.pyts               (@     '   #  >