3
ÕZð]×  ã               @   sR   d dl mZ d dlZd dlZd dlZd dlmZ d dlm	Z	 ej
dƒZdd„ ZdS )é    )Úprint_functionN)Ú
WheelError)Ú	WheelFilez6^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))\.dist-info$c                sd  ‡ fdd„t jˆ ƒD ƒ}t|ƒdkr4tdjˆ ƒƒ‚n|sFtdjˆ ƒƒ‚|d }tj|ƒjdƒ}|rn|d| 7 }tt j	j
ˆ |d	ƒƒ�&}d
d„ |D ƒ}|s¤tdj|ƒƒ‚W dQ R X tdd„ |D ƒƒ}tdd„ |D ƒƒ}	tdd„ |D ƒƒ}
dj
dj
|ƒdj
|	ƒdj
|
ƒgƒ}t j	j
|dj||ƒƒ}t|dƒ�,}tdj|ƒdd� tjjƒ  |jˆ ƒ W dQ R X tdƒ dS )aB  Repack a previously unpacked wheel directory into a new wheel file.

    The .dist-info/WHEEL file must contain one or more tags so that the target
    wheel file name can be determined.

    :param directory: The unpacked wheel directory
    :param dest_dir: Destination directory (defaults to the current directory)
    c                s0   g | ](}t jjt jjˆ |ƒƒrtj|ƒr|‘qS © )ÚosÚpathÚisdirÚjoinÚDIST_INFO_REÚmatch)Ú.0Úfn)Ú	directoryr   ú//tmp/pip-build-uspjrw0y/wheel/wheel/cli/pack.pyú
<listcomp>   s    zpack.<locals>.<listcomp>é   z+Multiple .dist-info directories found in {}z%No .dist-info directories found in {}r   Znameverú-ÚWHEELc             S   s(   g | ] }|j d ƒr|jdƒd jƒ ‘qS )zTag: ú r   )Ú
startswithÚsplitÚrstrip)r   Úliner   r   r   r   (   s    zCNo tags present in {}/WHEEL; cannot determine target wheel filenameNc             S   s   h | ]}|j d ƒd ’qS )r   r   )r   )r   Útagr   r   r   ú	<setcomp>.   s    zpack.<locals>.<setcomp>c             S   s   h | ]}|j d ƒd ’qS )r   r   )r   )r   r   r   r   r   r   /   s    c             S   s   h | ]}|j d ƒd ’qS )r   é   )r   )r   r   r   r   r   r   0   s    Ú.z	{}-{}.whlÚwzRepacking wheel as {}...Ú )ÚendÚOK)r   ÚlistdirÚlenr   Úformatr
   r   ÚgroupÚopenr   r	   Úsortedr   ÚprintÚsysÚstdoutÚflushZwrite_files)r   Údest_dirÚbuild_numberZdist_info_dirsZdist_info_dirZname_versionÚfÚtagsZimplsZabiversÚ	platformsZtaglineÚ
wheel_pathZwfr   )r   r   Úpack   s0    
"
r1   )Ú
__future__r   Úos.pathr   Úrer(   Z	wheel.clir   Zwheel.wheelfiler   Úcompiler
   r1   r   r   r   r   Ú<module>   s   
