U cÃf¶«ã@sÎddlmZddlZddlZddlZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZmZddlmZmZmZmZmZddlmZddlmZmZmZdd l m!Z!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  .e/¡Z0da1e2ed ƒr,d Z3n*ej4 5d ¡r@dZ3nej4dkrRdZ3ndZ3e 6d¡Z7e7sxdej8dd…Z7de7Z9e3e7Z:e*ƒ ;dd¡ ;dd¡Zd¡dZ=ndd„Z?e?ƒZ=[?e  @de jAe jBB¡ZCe  @de jAe jBB¡ZDe  @d¡ZEe  @d ¡ZFd!ZGd"ZHe jId#kr[^-]+) -(?P\d+[^-]*) (-(?P\d+[^-]*))? -(?P\w+\d+(\.\w+\d+)*) -(?P\w+) -(?P\w+(\.\w+)*) \.whl$ z7 (?P[^-]+) -(?P\d+[^-]*) (-(?P\d+[^-]*))?$ s \s*#![^\r\n]*s^(\s*#!("[^"]+"|\S+))\s+(.*)$s#!pythons #!pythonwú/cCs|S©Nr?©Úor?r?r@ÚhórFcCs| tjd¡S)NrB)ÚreplaceÚosÚseprDr?r?r@rFjrGr,cCs"trdd„t ¡DƒStjjSdS)NcSsg|] }|d‘qS)rr?©Ú.0Úsr?r?r@Ú vsz!_get_suffixes..)ÚimpZ get_suffixesÚ importlibÚ machineryÚEXTENSION_SUFFIXESr?r?r?r@Ú _get_suffixestsrScCsHtrt ||¡Stj ||¡}tj |¡}|tj|<|j  |¡|SdSrC) rOZ load_dynamicrPÚutilÚspec_from_file_locationÚmodule_from_specr8ÚmodulesÚloaderÚ exec_module)ÚnameÚpathÚspecÚmoduler?r?r@Ú _load_dynamic{s    r^c@s6eZdZdd„Zdd„Zdd„Zd dd „Zd d „ZdS) ÚMountercCsi|_i|_dSrC)Ú impure_wheelsÚlibs©Úselfr?r?r@Ú__init__‰szMounter.__init__cCs||j|<|j |¡dSrC)r`raÚupdate)rcÚpathnameÚ extensionsr?r?r@Úadds z Mounter.addcCs0|j |¡}|D]\}}||jkr|j|=qdSrC)r`Úpopra)rcrfrgÚkÚvr?r?r@Úremove‘s   zMounter.removeNcCs||jkr|}nd}|SrC)ra)rcÚfullnamer[Úresultr?r?r@Ú find_module—s zMounter.find_modulecCsh|tjkrtj|}nN||jkr,td|ƒ‚t||j|ƒ}||_| dd¡}t|ƒdkrd|d|_|S)Nzunable to find extension for %sr(rr) r8rWraÚ ImportErrorr^Ú __loader__ÚrsplitÚlenÚ __package__)rcrmrnr<r?r?r@Ú load_moduležs       zMounter.load_module)N)Ú__name__Ú __module__Ú __qualname__rdrhrlrorur?r?r?r@r_‡s  r_c@sîeZdZdZdZdZd4dd„Zedd „ƒZed d „ƒZ ed d „ƒZ e dd„ƒZ dd„Z e dd„ƒZdd„Zd5dd„Zdd„Zdd„Zdd„Zd6dd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd7d,d-„Zd.d/„Zd0d1„Zd8d2d3„ZdS)9ÚWheelz@ Class to build and install from Wheel files (PEP 427). )rrÚsha256NFcCs8||_||_d|_tg|_dg|_dg|_t ¡|_ |dkrRd|_ d|_ |j |_ nât |¡}|rš| d¡}|d|_ |d d d ¡|_ |d |_|j |_ nštj |¡\}}t |¡}|sÄtd |ƒ‚|rÖtj |¡|_ ||_ | d¡}|d|_ |d|_ |d |_|d  d¡|_|d d¡|_|d d¡|_dS)zB Initialise an instance using a (valid) filename. r3ÚnoneÚanyNÚdummyz0.1ÚnmZvnr'r&ZbnzInvalid name or filename: %rr%r(ZbiÚar)ÚsignZ should_verifyÚbuildverÚPYVERÚpyverÚabiÚarchrIÚgetcwdÚdirnamerZÚversionÚfilenameÚ _filenameÚNAME_VERSION_REÚmatchÚ groupdictrHr[ÚsplitÚ FILENAME_RErÚabspath)rcr‰r€Úverifyr/Úinfor‡r?r?r@rd·sD        ÿ    zWheel.__init__cCs^|jrd|j}nd}d |j¡}d |j¡}d |j¡}|j dd¡}d|j|||||fS)zJ Build and return a filename from the various components. r&r3r(r'z%s-%s%s-%s-%s-%s.whl)rr;rƒr„r…rˆrHrZ)rcrrƒr„r…rˆr?r?r@r‰às     ÿzWheel.filenamecCstj |j|j¡}tj |¡SrC)rIr[r;r‡r‰Úisfile)rcr[r?r?r@Úexistsñsz Wheel.existsccs4|jD](}|jD]}|jD]}|||fVqqqdSrC)rƒr„r…)rcrƒr„r…r?r?r@Útagsös   z Wheel.tagsc Csætj |j|j¡}d|j|jf}d|}t d¡}t |dƒž}|  |¡t t g}d}|D]f}zLt  ||¡} | | ¡,} || ƒ} t| d}|ržW5QR£WqÂW5QRXWqZtk r¾YqZXqZ|sØtdd |¡ƒ‚W5QRX|S)Nú%s-%sú %s.dist-infoúutf-8Úr)Úfileobjz8Invalid wheel, because metadata is missing: looked in %sz, )rIr[r;r‡r‰rZrˆÚcodecsÚ getreaderrÚget_wheel_metadatarrÚ posixpathÚopenr ÚKeyErrorÚ ValueError) rcrfÚname_verÚinfo_dirÚwrapperÚzfÚfnsrnÚfnÚmetadata_filenameÚbfÚwfr?r?r@Úmetadataýs.      ÿzWheel.metadatac CsXd|j|jf}d|}t |d¡}| |¡}t d¡|ƒ}t|ƒ}W5QRXt|ƒS)Nr–r—ÚWHEELr˜) rZrˆržr;rŸr›rœrÚdict)rcr¥r¢r£r¨r©rªÚmessager?r?r@rs  zWheel.get_wheel_metadatac Cs6tj |j|j¡}t|dƒ}| |¡}W5QRX|S)Nr™)rIr[r;r‡r‰rr)rcrfr¥rnr?r?r@r’&s z Wheel.infoc CsÔt |¡}|r|| ¡}|d|…||d…}}d| ¡krBt}nt}t |¡}|rfd| ¡d}nd}||}||}nT| d¡}| d¡} |dks || kr¦d} n|||d…d krÀd } nd} t| |}|S) Nspythonwó éÿÿÿÿrGó ó rr$s ) Ú SHEBANG_RErŒÚendÚlowerÚSHEBANG_PYTHONWÚSHEBANG_PYTHONÚSHEBANG_DETAIL_REÚgroupsÚfind) rcÚdatar/r´ÚshebangZdata_after_shebangZshebang_pythonÚargsÚcrÚlfÚtermr?r?r@Úprocess_shebang-s,       zWheel.process_shebangcCsh|dkr|j}ztt|ƒ}Wn tk r<td|ƒ‚YnX||ƒ ¡}t |¡ d¡  d¡}||fS)NzUnsupported hash algorithm: %ró=Úascii) Ú hash_kindÚgetattrÚhashlibÚAttributeErrorrÚdigestÚbase64Úurlsafe_b64encodeÚrstripÚdecode)rcr»rÄZhasherrnr?r?r@Úget_hashKsÿ  zWheel.get_hashc CsDt|ƒ}| |ddf¡t|ƒ}|D]}| |¡q&W5QRXdS)Nr3)Úlistr6rÚwriterow)rcÚrecordsÚ record_pathZarchive_record_pathÚwriterÚrowr?r?r@Ú write_recordWs  zWheel.write_recordc Cs¢g}|\}}|D]P\}}t|dƒ} |  ¡} W5QRXd| | ¡} tj |¡} | || | f¡qtj |d¡}ttj |d¡ƒ}|  |||¡| ||f¡dS)NÚrbz%s=%sÚRECORD) rŸÚreadrÍrIr[Úgetsizer6r;Úto_posixrÔ) rcr’ÚlibdirÚ archive_pathsrÐÚdistinfor£ÚapÚpÚfr»rÈÚsizer?r?r@Ú write_records^s   zWheel.write_recordsc CsFt|dtjƒ.}|D]"\}}t d||¡| ||¡qW5QRXdS)NÚwzWrote %s to %s in wheel)rÚzipfileÚ ZIP_DEFLATEDÚloggerÚdebugÚwrite)rcrfrÛr¥rÝrÞr?r?r@Ú build_zipns zWheel.build_zipc" s’|dkr i}tt‡fdd„dƒƒd}|dkrFd}tg}tg}tg}nd}tg}d g}d g}| d |¡|_| d |¡|_| d |¡|_ ˆ|} d|j |j f} d| } d| } g} dD]Þ}|ˆkrÄq¶ˆ|}t j  |¡r¶t  |¡D]°\}}}|D] }tt j  ||¡ƒ}t j  ||¡}tt j  | ||¡ƒ}|  ||f¡|dkrð| d¡sðt|dƒ}| ¡}W5QRX| |¡}t|dƒ}| |¡W5QRXqðqâq¶| }d}t  |¡D]´\}}}||kr t|ƒD]8\}}t|ƒ}| d¡rÄt j  ||¡}||=qþqÄ|s tdƒ‚|D]H}t|ƒ d¡r(qt j  ||¡}tt j  ||¡ƒ}|  ||f¡qq¨t  |¡}|D]B}|dkrltt j  ||¡ƒ}tt j  | |¡ƒ}|  ||f¡qld|p¼|jdtd|g}|jD] \}}}| d|||f¡qÔt j  |d¡}t|dƒ}| d  |¡¡W5QRXtt j  | d¡ƒ}|  ||f¡d!d"„} t | | d#} | !|| f| | ¡t j  |j"|j#¡}!| $|!| ¡|!S)$z‰ Build a wheel from files in specified paths, and use any specified tags when determining the name of the wheel. Ncs|ˆkSrCr?rD©Úpathsr?r@rF|rGzWheel.build..)ÚpurelibÚplatlibrrìÚfalseÚtruer{r|rƒr„r…r–ú%s.datar—)r»ÚheadersÚscriptsrñú.exerÕÚwbú .dist-infoz(.dist-info directory expected, not found)z.pycz.pyo)rÖÚ INSTALLERZSHAREDr¬zWheel-Version: %d.%dzGenerator: distlib %szRoot-Is-Purelib: %sz Tag: %s-%s-%sr¬râÚ cSs*|d}| d¡}d|kr"|d7}||fS)NrrBrôi')Úcount)ÚtrÝÚnr?r?r@ÚsorterØs  zWheel.build..sorter)Úkey)%rÎr ÚIMPVERÚABIÚARCHr‚Úgetrƒr„r…rZrˆrIr[ÚisdirÚwalkr r;ÚrelpathrÙr6ÚendswithrŸr×rÁrçÚ enumerateÚAssertionErrorÚlistdirÚ wheel_versionrr•Úsortedrár‡r‰rè)"rcrêr•rZlibkeyÚis_pureZ default_pyverZ default_abiZ default_archrÚr¢Údata_dirr£rÛrûr[ÚrootÚdirsÚfilesr§rÞÚrprÝrßr»rÜÚiÚdnÚwheel_metadatarƒr„r…rúrfr?rér@Úbuildtsš         ý   z Wheel.buildcCs | d¡S)zl Determine whether an archive entry should be skipped when verifying or installing. )rBz /RECORD.jws)r)rcÚarcnamer?r?r@Ú skip_entryészWheel.skip_entrycC KsŽ|j}| d¡}| dd¡}| dd¡}tj |j|j¡}d|j|jf} d| } d| } t  | t ¡} t  | d¡} t  | d ¡}t   d ¡}t |d ƒð}| | ¡}||ƒ}t|ƒ}W5QRX|d  d d¡}tdd„|Dƒƒ}||jkrø|rø||j|ƒ|ddkr|d}n|d}i}| |¡8}t|d"}|D]}|d}|||<q8W5QRXW5QRXt  | d¡}t  | d¡}t  | dd¡}t|d}d|_tj } g}!t ¡}"|"|_d|_z¶z„| ¡D]Ö}#|#j}$t|$t ƒrè|$}%n |$ !d ¡}%| "|%¡rqÊ||%}|dr4t#|#j$ƒ|dkr4t%d|%ƒ‚|dr–|d dd¡\}&}'| |$¡}| &¡}(W5QRX| '|(|&¡\})}*|*|'kr–t%d|$ƒ‚|r¼|% (||f¡r¼t) *d |%¡qÊ|% (|¡oÒ|% +d!¡ }+|% (|¡r |% d"d¡\})},}-tj ||,t,|-ƒ¡}.n$|%| |fkrqÊtj |t,|%ƒ¡}.|+s,| |$¡}| -||.¡W5QRXtjd#krxt .|.|#j/d$?d%@¡|! 0|.¡|sÖ|drÖt|.d&ƒ4}| &¡}(| '|(|&¡\})}/|/|*krÌt%d'|.ƒ‚W5QRX| r |. +d(¡r z|j1|.|d)}0|! 0|0¡Wn$t2k r(t)j3d*dd+YnXnttj 4t,|$ƒ¡}1tj |"|1¡}2| |$¡}| -||2¡W5QRXtj |.¡\}3}1|3|_| 5|1¡}4| 6|4¡|! 7|4¡qÊ|r¼t) *d,¡d}5ntd}6|j8d }|d-kr¢t  | d.¡}7zž| |7¡}t9|ƒ}8W5QRXi}6d/D]r}9d0|9}:|:|8kri|6d1|9<};|8|: :¡D]<} ?|¡ d6¡}6|6rØ|6 d7¡}6W5QRXWn t2k rt) 3d8¡YnX|6rÐ|6 d9i¡}>|6 d:i¡}?|>s0|?rÐ| dd¡}@tj @|@¡sRtAd;ƒ‚|@|_|> B¡D]*\}:}<|5 E||¡}|r|! 0|¡|5 F|!|d?|¡|5WW¢.zRoot-Is-Purelibrîrërì©Ústreamrr3rñ)Údry_runTNr$úsize mismatch for %sú=údigest mismatch for %szlib_only: skipping %sròrBÚposixéiÿrÕzdigest mismatch on write for %sz.py)Úhashed_invalidationzByte-compilation failed)Úexc_infozlib_only: returning Nonez1.0zentry_points.txt)ÚconsoleÚguiz %s_scriptszwrap_%sz%s:%sz [%s]ú,zAUnable to read legacy script metadata, so cannot generate scriptsrgzpython.commandsz8Unable to read JSON metadata, so cannot generate scriptsZ wrap_consoleZwrap_guizValid script path not specifiedz%s = %sr%ÚlibÚprefixzinstallation failed.)IrrÿrIr[r;r‡r‰rZrˆržrr›rœrrŸrrŽÚtuplerrrÚrecordr8Údont_write_bytecodeÚtempfileÚmkdtempÚ source_dirÚ target_dirÚshutilÚrmtreeÚinfolistÚ isinstancer rÌrÚstrÚ file_sizerr×rÍÚ startswithrårærrÚ copy_streamÚchmodÚ external_attrr6Ú byte_compileÚ ExceptionÚwarningÚbasenameÚmakeÚset_executable_modeÚextendr’rÚvaluesr(ÚsuffixÚflagsÚjsonÚloadrr¡Úitemsr r­Zwrite_shared_locationsZwrite_installed_filesÚ exceptionÚrollback)CrcrêÚmakerÚkwargsrrrZbc_hashed_invalidationrfr¢r r£Ú metadata_nameÚwheel_metadata_nameÚ record_namer¤r¥Úbwfrªr®ZwvZ file_versionrÚrÐr©ÚreaderrÓrÞZdata_pfxZinfo_pfxZ script_pfxÚfileopÚbcZoutfilesÚworkdirÚzinforÚ u_arcnameÚkindÚvaluer»r'rÈZ is_scriptÚwhererÚoutfileZ newdigestZpycr§ZworknamerÚ filenamesÚdistÚcommandsÚepZepdatarûrjr+rkrMÚconsole_scriptsÚ gui_scriptsZ script_dirÚscriptÚoptionsr?r?r@Úinstallùsb  ÿ                ÿ   ÿ   ÿ    ÿ   þþÿ                     ÿ  z Wheel.installcCs8tdkr4tj tƒtdƒdtjdd…¡}t|ƒatS)Nz dylib-cachez%s.%sr$) ÚcacherIr[r;rr4r8r9r)rcÚbaser?r?r@Ú_get_dylib_cacheés ÿzWheel._get_dylib_cachec Cshtj |j|j¡}d|j|jf}d|}t |d¡}t  d¡}g}t |dƒ}zð|  |¡Ü}||ƒ} t   | ¡} | ¡} |  |¡} tj | j| ¡} tj | ¡sªt | ¡|  ¡D]‚\}}tj | t|ƒ¡}tj |¡sÞd}n6t |¡j}tj |¡}| |¡}tj|jŽ}||k}|r&| || ¡| ||f¡q²W5QRXWntk rXYnXW5QRX|S)Nr–r—Z EXTENSIONSr˜r™T)rIr[r;r‡r‰rZrˆržr›rœrrŸrDrErdÚ prefix_to_dirrcrÚmakedirsrFrr”ÚstatÚst_mtimeÚdatetimeÚ fromtimestampÚgetinfoÚ date_timeÚextractr6r )rcrfr¢r£rr¤rnr¥r©rªrgrbr(Z cache_baserZrÚdestrmZ file_timer’Z wheel_timer?r?r@Ú_get_extensionsòsB         ÿ   zWheel._get_extensionscCst|ƒS)zM Determine if a wheel is compatible with the running system. )Ú is_compatiblerbr?r?r@rpszWheel.is_compatiblecCsdS)zP Determine if a wheel is asserted as mountable by its metadata. Tr?rbr?r?r@Ú is_mountableszWheel.is_mountablecCs´tj tj |j|j¡¡}| ¡s2d|}t|ƒ‚| ¡sJd|}t|ƒ‚|t jkrbt   d|¡nN|rtt j  |¡nt j  d|¡| ¡}|r°tt jkr¤t j  t¡t ||¡dS)Nz)Wheel %s not compatible with this Python.z$Wheel %s is marked as not mountable.z%s already in pathr)rIr[rr;r‡r‰rprrqr8rårær6ÚinsertroÚ_hookÚ meta_pathrh)rcr6rfÚmsgrgr?r?r@Úmount!s"   z Wheel.mountcCsrtj tj |j|j¡¡}|tjkr2t d|¡n.get_versioncSsàd}z|t|ƒ| d¡}|dkr*d|}nTdd„||dd… d¡Dƒ}|dd7<d |d|…d d d „|Dƒ¡f}Wn tk r t d |¡YnX|rÜt|d }||_|  t ¡}|j ||dt d||¡dS)Nr&rz%s+1cSsg|] }t|ƒ‘qSr?rrKr?r?r@rNsz8Wheel.update..update_version..rr(r°z%s+%scss|]}t|ƒVqdSrC)r4rr?r?r@Ú Ÿsz7Wheel.update..update_version..z0Cannot update non-compliant (PEP-440) version %rrz)r[ÚlegacyzVersion updated from %r to %r) rrºrŽr;rrårær rˆrrrç)rˆr[Úupdatedrr<Úmdr~r?r?r@Úupdate_version•s,   ÿþ   z$Wheel.update..update_versionr–r—rÖr™r˜rxryNz.whlz wheel-update-)rBr(ÚdirzNot a directory: %r)rIr[r;r‡r‰rZrˆržrrr2r3r rÌrrmrr,ÚmkstempÚcloserrÎrFrárèr0Úcopyfile)rcÚmodifierÚdest_dirrJr|rrfr¢r£rMrRr¥r{rSrrTr[Zoriginal_versionr'ÚmodifiedÚcurrent_versionÚfdÚnewpathrÛrÜr’r?r?r@rezs`       ÿ    þ  ÿ   z Wheel.update)NFF)N)NN)F)N)rvrwrxÚ__doc__rrÄrdÚpropertyr‰r”r•rr«rr’rÁrÍrÔrárèrrrardrorprqrvrwr‘rer?r?r?r@ry¯s@ )        uq #  8rycCsZddl}| ¡}g}|ddkrV|d d¡D]}| | ¡rFt|ƒnd¡q.t|ƒ}|S)NrÚglibcrr()ÚplatformÚlibc_verrŽr6Úisdigitrr))rÚverrnrMr?r?r@Ú_get_glibc_versionás r“c Cs`tg}td}ttjddddƒD]}| d |t|ƒg¡¡q$g}tƒD]$}| d¡rL| |  dd¡d¡qL|  ¡t dkrŽ|  dt ¡| d¡g}t g}tjd kr†t d t ¡}|r†| ¡\}}}} t|ƒ}| g} | d krð|  d ¡| d kr|  d¡| dkr|  d¡| dkr,|  d¡| dkr@|  d¡|dkr†| D]*} d|||| f} | t krN| | ¡qN|d8}q@|D]} |D]} | d t|df¡| | f¡| dkr”tj d¡r”|  dd¡} tƒ}t|ƒdkr”|dkr| d t|df¡| d| f¡|dkrH| d t|df¡| d| f¡|dkrt| d t|df¡| d| f¡| d t|df¡| d|d|d| ff¡q”qŠt|ƒD]L\}}| d t|f¡ddf¡|dkr´| d t|df¡ddf¡q´t|ƒD]L\}}| d d |f¡ddf¡|dkr | d d |df¡ddf¡q t|ƒS)!zG Return (pyver, abi, arch) tuples compatible with this Python. rrr°r3z.abir(r$r{Údarwinz(\w+)_(\d+)_(\d+)_(\w+)$)Úi386ÚppcÚfat)r•r–Úx86_64Zfat3)Úppc64r˜Úfat64)r•r˜Úintel)r•r˜r›r–r™Ú universalz %s_%s_%s_%sÚlinuxZlinux_)r$éz manylinux1_%s)r$é zmanylinux2010_%s)r$ézmanylinux2014_%szmanylinux_%s_%s_%sr|r%)r4Úranger8r9r6r;r4rSr6rŽÚsortrýrrrþrÚrerŒr¹rr7rHr“rsrÚset)ÚversionsÚmajorÚminorÚabisrBrnÚarchesr/rZr…ÚmatchesrŒrMr„r<rrˆr?r?r@Úcompatible_tagsìsŠ                      ÿ ÿ ÿÿÿ  " "r«cCs\t|tƒst|ƒ}d}|dkr"t}|D]0\}}}||jkr&||jkr&||jkr&d}qXq&|S)NFT)r3ryÚCOMPATIBLE_TAGSrƒr„r…)Úwheelr•rnr’r„r…r?r?r@rpAs rp)N)YÚ __future__rrÉr›riÚemailrrÆrDÚloggingrIržr£r0r8r,rãr3rrÚcompatrrr r r Zdatabaser r«r rrrTrrrrrrrrrrrˆrrÚ getLoggerrvrårbÚhasattrr7rr6r5r4r9r‚rürHrþrýrŽrAÚcompileÚ IGNORECASEÚVERBOSErr‹r³r¸r·r¶rJrÙrOZimportlib.machineryrPÚimportlib.utilrSr^Úobjectr_rsryr“r«r¬rpr?r?r?r@Úsš   0      ÷  û      %8 P