î
!dÝV  ã               @   sX   d  Z  d d l Z d d l Z d d l Z e j d ƒ Z d d „  Z d d d „ Z d S)	z
Archive tools for wheel.
é    NÚwheelc             C   sW   t  j j t  j ƒ } t  j j |  ƒ }  z t  j | ƒ t |  ƒ SWd t  j | ƒ Xd S)zWArchive all files under `base_dir` in a whl file and name it like
    `base_name`.
    N)ÚosÚpathÚabspathÚcurdirÚchdirÚmake_wheelfile_inner)Ú	base_nameÚbase_dirZolddir© r   ú./tmp/pip-build-0jahl3lb/wheel/wheel/archive.pyÚarchive_wheelfile   s    r   Ú.c                sR  |  d } t  j d | | ƒ t j t | d ƒ d d t j ƒ‰  i d d 6d d	 6d
 d 6} g  } ‡  f d d †  } x¢ t j | ƒ D]‘ \ } } } x | D]w }	 t j j	 t j j
 | |	 ƒ ƒ }
 t j j |
 ƒ rš | j d ƒ r| j | j |	 d ƒ |
 f ƒ q| |
 ƒ qš qš Wq„ W| j ƒ  x | D] \ } }
 | |
 ƒ q*Wˆ  j ƒ  | S)zhCreate a whl file from all the files under 'base_dir'.

    Places .dist-info at the end of the archive.z.whlz#creating '%s' and adding '%s' to itzwb+ÚwÚcompressioné   ÚWHEELé   ÚMETADATAé   ÚRECORDc                s%   ˆ  j  |  |  ƒ t j d |  ƒ d  S)Nzadding '%s')ÚwriteÚlogÚinfo)r   )Úzipr   r   Ú	writefile)   s    z'make_wheelfile_inner.<locals>.writefilez
.dist-infor   )r   r   ÚzipfileÚZipFileÚopenÚZIP_DEFLATEDr   Úwalkr   ÚnormpathÚjoinÚisfileÚendswithÚappendÚgetÚsortÚclose)r	   r
   Úzip_filenameÚscoreÚdeferredr   ÚdirpathÚdirnamesÚ	filenamesÚnamer   r   )r   r   r      s&    
!"

r   )	Ú__doc__ÚloggingÚos.pathr   r   Ú	getLoggerr   r   r   r   r   r   r   Ú<module>   s   