3
#+]                 @   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 }|st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   1/tmp/pip-install-652y2hkr/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   
