ôY1ã@sýddlZddlZddlZddlZddlZddlZddlZ ddl m Z ddl m Z ddlmZddlmZddlmZejdejƒZdd „Zejjd d „Zd d „ZedkrùeƒdS)éN)Ú make_archive)Úrmtree)Úarchive_wheelfile)ÚArgumentParser)ÚiglobzX(^|/)(?P[^/]+?)-(?P.+?) (-(?P.+?))?(-(?P.+?))?.egg-info(/|$)c Cs7d}|r4tj|ƒ}|s4td|fƒ‚|jdƒ\}}}|setd|fƒ‚|dd…}|jdƒ\}}}|r½|jdƒr½|}|jddƒ}nd }|jdƒ\}}} |sôtd|fƒ‚|r|jd ƒ}|jd ƒ}td |d |d | d |ƒS)axExtract metadata from filenames. Extracts the 4 metadataitems needed (name, version, pyversion, arch) from the installer filename and the name of the egg-info directory embedded in the zipfile (if any). The egginfo filename has the format:: name-ver(-pyver)(-arch).egg-info The installer filename has the format:: name-ver.arch(-pyver).exe Some things to note: 1. The installer filename is not definitive. An installer can be renamed and work perfectly well as an installer. So more reliable data should be used whenever possible. 2. The egg-info data should be preferred for the name and version, because these come straight from the distutils metadata, and are mandatory. 3. The pyver from the egg-info data should be ignored, as it is constructed from the version of Python used to build the installer, which is irrelevant - the installer filename is correct here (even to the point that when it's not there, any version is implied). 4. The architecture must be taken from the installer filename, as it is not included in the egg-info data. 5. Architecture-neutral installers still have an architecture because the installer format itself (being executable) is architecture-specific. We should therefore ignore the architecture if the content is pure-python. Nz!Egg info filename %s is not validú-z"Installer filename %s is not validéÚpyÚ.Úzpy2.py3ÚnameÚverÚarchÚpyveréüÿÿÿ) Ú egg_info_reÚsearchÚ ValueErrorÚ partitionÚ rpartitionÚ startswithÚreplaceÚgroupÚdict) Z wininfo_nameÚ egginfo_nameZegginfoZw_nameÚsepÚrestZrest2Zw_pyverZw_verZw_arch©rú4/tmp/pip-build-3puug3g5/wheel/wheel/wininst2wheel.pyÚ parse_infos0!   rcCstj|ƒ}d}x'|jƒD]}d|kr"|}Pq"Wttjj|ƒ|ƒ}d}x-|jƒD]}|jj dƒrmd}PqmW|r¥ddi}n ddi}d|} d | } g} d}xõ|jƒD]ç}|jj d d ƒ\} } | j ƒ} |j | dƒ}|dkr=| | j ƒd }|j}|| }||_|j |=||j |<|rƒ| j|ƒ|sÞ|jdƒr¡|}qÞd |krÞ|jd ƒ\}}}qÞWtjd dƒ}|j|| ƒd}|d}|dpdjddƒjddƒ}|r/d}|dkrM|jddƒ}dj| |||fƒ}tjjtjjƒƒ}||_tjj|d| ƒ}|jtjj||ƒ|ƒ|j|ddƒ|j||ƒttjj||ƒ|ƒt |ƒdS)Nz .egg-infoTZPLATLIBFÚpurelibr Úplatlibz%(name)s-%(ver)sz%s.data/ú/éz .egg-info/ÚsuffixZ_b2wÚnonerrÚanyr Ú_rr Úcpz %s.dist-infoÚ generatorZ wininst2wheel)!ÚzipfileÚZipFileÚnamelistrÚosÚpathÚbasenameÚinfolistÚfilenamerÚsplitÚlowerÚgetÚ NameToInfoÚappendÚendswithrÚtempfileÚmkdtempÚ extractallrÚjoinÚwheelÚ bdist_wheelÚ distutilsÚdistÚ DistributionÚroot_is_purelibZegg2distZwrite_wheelfileZ write_recordrr)r.Údest_dirZbdwrr1ÚinforAÚzipinfoÚpathsZ dist_infoÚdatadirÚmembersÚkeyr/ZbasepathZoldnameZnewnamerr'ÚdirÚabirrÚ wheel_nameZbwZ dist_info_dirrrrÚbdist_wininst2wheelZsv               (   rLcCsàtƒ}|jdddddƒ|jdddtjjdd ƒ|jd d d d ƒ|jƒ}xs|jD]h}x_t|ƒD]Q}|jr«t j j dj |ƒƒt ||jƒ|jrƒt j j dƒqƒWqpWdS)NÚ installersÚnargsÚ*ÚhelpzInstallers to convertz --dest-dirz-dÚdefaultz/Directory to store wheels (default %(default)s)z --verbosez-vÚactionÚ store_truez{0}... zOK )rÚ add_argumentr-r.ÚcurdirÚ parse_argsrMrÚverboseÚsysÚstdoutÚwriteÚformatrLrB)ÚparserÚargsÚpatÚ installerrrrÚmain«s    r`Ú__main__)Úos.pathr-ÚrerXr8r*Zwheel.bdist_wheelr<Údistutils.distr>Zdistutils.archive_utilrÚshutilrZ wheel.archiverÚargparserÚglobrÚcompileÚVERBOSErrr.rUrLr`Ú__name__rrrrÚs$        HQ