3 K]b@sdZddlmZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZddlmZddlm ZddlmZdd lmZejd ejjZd Zd d ZGdddeZdS)zWheels support.) get_platformN) Distribution PathMetadata parse_version)canonicalize_name)PY3)r) pep425tags)write_requirementsz^(?P.+?)-(?P\d.*?) ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) )\.whl$ztry: __import__('pkg_resources').declare_namespace(__name__) except ImportError: __path__ = __import__('pkgutil').extend_path(__path__, __name__) c Csxtj|D]\}}}tjj||}x6|D].}tjj||}tjj|||}tj||q*WxXttt|D]D\} } tjj|| }tjj||| }tjj |sntj|||| =qnWq Wx0tj|ddD]\}}}| st tj |qWdS)zDMove everything under `src_dir` to `dst_dir`, and delete the former.T)topdownN) oswalkpathrelpathjoinrenamesreversedlist enumerateexistsAssertionErrorrmdir) Zsrc_dirZdst_dirdirpathZdirnames filenamessubdirfsrcdstndr/usr/lib/python3.6/wheel.pyunpack!s    r!c@s<eZdZddZddZddZddZd d Zd d Zd S)WheelcCsTttjj|}|dkr$td|||_x$|jjD]\}}t|||q8WdS)Nzinvalid wheel name: %r) WHEEL_NAMEr r basename ValueErrorfilename groupdictitemssetattr)selfr&matchkvrrr __init__9s  zWheel.__init__cCs&tj|jjd|jjd|jjdS)z>List tags (py_version, abi, platform) supported by this wheel..) itertoolsproduct py_versionsplitabiplatform)r*rrr tagsAs z Wheel.tagscs$tjtfdd|jDdS)z5Is the wheel is compatible with the current platform?c3s|]}|krdVqdS)TNr).0t)supported_tagsrr Jsz&Wheel.is_compatible..F)rZ get_supportednextr6)r*r)r9r is_compatibleGszWheel.is_compatiblecCs*t|j|j|jdkrdntdjdS)Nany) project_nameversionr5z.egg)rr>r?r5regg_name)r*rrr r@LszWheel.egg_namecCsJx<|jD]0}tj|}|jdr t|jt|jr |Sq WtddS)Nz .dist-infoz.unsupported wheel format. .dist-info not found)Znamelist posixpathdirnameendswithr startswithr>r%)r*zfmemberrBrrr get_dist_infoRs   zWheel.get_dist_infocstj|jd|j|jf}|jd|fdd}|d}|d}t|jd}td|koxtd knstd |t j |j |t j j |tj|t|d d d tttjfddjD}t j j |d}t j|t jt j j |dt j j |dtt|dd} t| jddt j j |dt j j |t j j d} t j j| rt j j |dd} t j | xVt j| D]H} | jdrt jt j j | | n t jt j j | | t j j | | qWt j| x0t t j jfddd#DD]} t!| |q$Wt j jrPt jt j j |d}t j j|rt"|}|j#j$}WdQRXxr|D]j}t j j |f|j$d }t j j |d!}t j j|rt j j| rt"|d"}|j%t&WdQRXqWWdQRXdS)$z"Install wheel as an egg directory.z%s-%sz%s.datac sHjtj|,}tr&|jjdn|j}tjjj |SQRXdS)Nzutf-8) openrArrreaddecodeemailparserZParserZparsestr)namefpvalue) dist_inforErr get_metadatabsz*Wheel.install_as_egg..get_metadataZWHEELZMETADATAz Wheel-Versionz1.0z2.0dev0z$unsupported wheel format version: %s)ZmetadatacSsd|_t|S)N)Zmarkerstr)reqrrr raw_reqxsz%Wheel.install_as_egg..raw_reqc s6i|].}ttfddtj|fD|qS)c3s|]}|kr|VqdS)Nr)r7rS)install_requiresrr r:~sz2Wheel.install_as_egg...)rsortedmaprequires)r7Zextra)distrUrTrr |sz(Wheel.install_as_egg..zEGG-INFOzPKG-INFO)rUextras_require)Zattrsegg_infoNz requires.txtscriptsz.pycc3s|]}tjj|VqdS)N)r r r)r7r) dist_datarr r:sz'Wheel.install_as_egg..dataheaderspurelibplatlibznamespace_packages.txtr/z __init__.pyw)r_r`rarb)'zipfileZZipFiler&r>r?rGrgetr%r mkdirZ extractallr rrZ from_locationrrrVrWrXZextrasrenameSetuptoolsDistributiondictr Zget_command_objrlistdirrCunlinkrfilterr!rHrIr3writeNAMESPACE_PACKAGE_INIT)r*Zdestination_eggdirZ dist_basenamerQZwheel_metadataZ dist_metadataZ wheel_versionr[r\Z setup_distZdist_data_scriptsZegg_info_scriptsentryrZnamespace_packagesrNmodZmod_dirZmod_initr)rYr^rPrUrTrEr install_as_egg\sr                  zWheel.install_as_eggN) __name__ __module__ __qualname__r.r6r<r@rGrqrrrr r"7s  r")__doc__Zdistutils.utilrrKr0r rArerdZ pkg_resourcesrrrZ!setuptools.extern.packaging.utilsrZsetuptools.extern.sixrZ setuptoolsrhrZsetuptools.command.egg_infor compileVERBOSEr+r#rnr!objectr"rrrr s&