ó
.¿”Wc           @   sj   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z e j d ƒ Z d „  Z d d „ Z	 d S(   s   
Archive tools for wheel.
iÿÿÿÿNt   wheelc         C   sW   t  j j t  j ƒ } t  j j |  ƒ }  z t  j | ƒ t |  ƒ SWd t  j | ƒ Xd S(   sW   Archive all files under `base_dir` in a whl file and name it like
    `base_name`.
    N(   t   ost   patht   abspatht   curdirt   chdirt   make_wheelfile_inner(   t	   base_namet   base_dirt   olddir(    (    s,   /tmp/pip-build-Q3rTTP/wheel/wheel/archive.pyt   archive_wheelfile   s    t   .c            s˜  |  d } t  j d | | ƒ t j j d ƒ } | d k rD d } n t j t | ƒ ƒ d d !} t	 j
 t | d ƒ d d t	 j ƒ‰  i d	 d
 6d d 6d d 6} g  } ‡  f d †  } x¥ t j | ƒ D]” \ } }	 }
 x‚ |
 D]z } t j j t j j | | ƒ ƒ } t j j | ƒ rÚ | j d ƒ rD| j | j | d ƒ | f ƒ qT| | | ƒ qÚ qÚ WqÄ W| j ƒ  x! | D] \ } } | | | ƒ qmWˆ  j ƒ  | S(   sh   Create a whl file from all the files under 'base_dir'.

    Places .dist-info at the end of the archive.s   .whls#   creating '%s' and adding '%s' to itt   SOURCE_DATE_EPOCHi    i   s   wb+t   wt   compressioni   t   WHEELi   t   METADATAi   t   RECORDc            s®   t  j |  ƒ } | d  k r= t j | j ƒ } | d d !} n  t j |  | ƒ } | j d >| _	 t j
 | _ t |  d ƒ  } ˆ  j | | j ƒ  ƒ Wd  QXt j d |  ƒ d  S(   Ni    i   i   t   rbs   adding '%s'(   R   t   statt   Nonet   timet   gmtimet   st_mtimet   zipfilet   ZipInfot   st_modet   external_attrt   ZIP_DEFLATEDt   compress_typet   opent   writestrt   readt   logt   info(   R   t	   date_timet   stt   mtimet   zinfot   fp(   t   zip(    s,   /tmp/pip-build-Q3rTTP/wheel/wheel/archive.pyt	   writefile4   s    s
   .dist-infoN(   R!   R"   R   t   environt   getR   R   R   t   intR   t   ZipFileR   R   t   walkR   t   normpatht   joint   isfilet   endswitht   appendt   sortt   close(   R   R   t   zip_filenamet	   timestampR#   t   scoret   deferredR)   t   dirpatht   dirnamest	   filenamest   nameR   (    (   R(   s,   /tmp/pip-build-Q3rTTP/wheel/wheel/archive.pyR      s.    
	!"

(
   t   __doc__R   R   t   loggingt   os.pathR   t	   getLoggerR!   R
   R   (    (    (    s,   /tmp/pip-build-Q3rTTP/wheel/wheel/archive.pyt   <module>   s   	