B
    @)H[o  ã               @   s¼   d dl Zd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ d dlmZ d dlZd dlmZ e dej¡Zdd„ Zejjfd	d
„ZG dd„ dejjƒZdd„ Zedkr¸eƒ  dS )é    N)ÚArgumentParser)Úiglob)Úrmtree)Úarchive_wheelfilezX(^|/)(?P<name>[^/]+?)-(?P<ver>.+?)
    (-(?P<pyver>.+?))?(-(?P<arch>.+?))?.egg-info(/|$)c       
      C   sÎ   d}|r$t  |¡}|s$td|f ƒ‚|  d¡\}}}|sFtd| f ƒ‚|dd… }| d¡\}}}|r‚| d¡r‚|}| dd¡}nd	}| d¡\}}}	|s¨td| f ƒ‚|rÀ| d
¡}| d¡}|||	|dœS )at  Extract 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Ú.Ú zpy2.py3ÚnameÚver)r   r   ÚarchÚpyver)Úegg_info_reÚsearchÚ
ValueErrorÚ	partitionÚ
rpartitionÚ
startswithÚreplaceÚgroup)
Zwininfo_nameÚegginfo_nameZegginfoZw_nameÚsepÚrestZrest2Zw_pyverZw_verZw_arch© r   úVC:\Users\HIRONO~1\AppData\Local\Temp\pip-install-qz7kpjmn\wheel\wheel\wininst2wheel.pyÚ
parse_info   s*    !


r   c             C   s‚  t  | ¡}d }x| ¡ D ]}d|kr|}P qW ttj | ¡|ƒ}d}x"| ¡ D ]}|j 	d¡rNd}P qNW |rvddi}nddi}d| }	d	|	 }
g }d}x²| ¡ D ]¦}|j 
d
d¡\}}| ¡ }| |d ¡}|d krâ|
| ¡  d
 }|j}|| }||_|j|= ||j|< |�r| |¡ |s | d¡�r.|}q d|kr | d
¡\}}}q W tjdd�}| ||¡ d}|d }|d �pzd dd¡ dd¡}|�r–d}|dk�r¬| dd¡}d |	|||f¡}|�rØtj tj ¡ ¡}nttj ¡ ƒ}||_||_d|_|d �pd|_|�s d|_ |||f|_!tj |d|	 ¡}| "tj ||¡|¡ |j#|dd� | $||¡ t%tj ||¡|ƒ t&|ƒ d S )Nz	.egg-infoTZPLATLIBFÚpurelibr
   Úplatlibz%(name)s-%(ver)sz%s.data/ú/é   z
.egg-info/Z_b2w)ÚsuffixÚnoner   r   Úanyr	   Ú_r   r   Úcpz%s.dist-infoZwininst2wheel)Ú	generator)'ÚzipfileÚZipFileÚnamelistr   ÚosÚpathÚbasenameÚinfolistÚfilenamer   ÚsplitÚlowerÚgetÚ
NameToInfoÚappendÚendswithr   ÚtempfileÚmkdtempÚ
extractallr   ÚjoinÚwheelÚbdist_wheelÚ	distutilsÚdistÚDistributionÚ_bdist_wheel_tagZroot_is_pureÚ
python_tagZplat_name_suppliedÚ	plat_nameÚfull_tag_suppliedÚfull_tagZegg2distZwrite_wheelfileZwrite_recordr   r   )r+   Údest_dirZbdwr   r.   ÚinfoÚroot_is_purelibÚzipinfoÚpathsZ	dist_infoÚdatadirÚmembersÚkeyr,   ZbasepathZoldnameZnewnamer   r$   ÚdirÚabir   r   Ú
wheel_nameZbwZdist_info_dirr   r   r   Úbdist_wininst2wheelZ   s†    




rN   c                   s$   e Zd ZdZdZ‡ fdd„Z‡  ZS )r>   FNc                s(   | j r| jd k	r| jS tt| ƒ ¡ S d S )N)rA   rB   Úsuperr>   Úget_tag)Úself)Ú	__class__r   r   rP   Á   s    z_bdist_wheel_tag.get_tag)Ú__name__Ú
__module__Ú__qualname__rA   rB   rP   Ú__classcell__r   r   )rR   r   r>   ¸   s   r>   c              C   s¢   t ƒ } | jdddd� | jddtjjdd� | jd	d
dd� |  ¡ }xX|jD ]N}xHt|ƒD ]<}|jr|t	d 
|¡ƒ tj ¡  t||jƒ |jrZt	dƒ qZW qLW d S )NÚ
installersÚ*zInstallers to convert)ÚnargsÚhelpz
--dest-dirz-dz/Directory to store wheels (default %(default)s))ÚdefaultrZ   z	--verbosez-vÚ
store_true)Úactionz{}... ÚOK)r   Úadd_argumentr*   r+   ÚcurdirÚ
parse_argsrW   r   ÚverboseÚprintÚformatÚsysÚstdoutÚflushrN   rC   )ÚparserÚargsÚpatÚ	installerr   r   r   ÚmainÈ   s    
rl   Ú__main__)Údistutils.distr;   Úos.pathr*   Úrere   r5   r'   Úargparser   Úglobr   Úshutilr   Zwheel.bdist_wheelr9   Zwheel.archiver   ÚcompileÚVERBOSEr   r   r+   r`   rN   r:   r>   rl   rS   r   r   r   r   Ú<module>   s$   
G^