ó
Ð²Ebc           @   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 Z e j d „  ƒ Z d „  Z	 d „  Z
 d S(   iÿÿÿÿNc          c   s*   t  j ƒ  }  z	 |  VWd t j |  ƒ Xd S(   s2   Create a temporary directory in a context manager.N(   t   tempfilet   mkdtempt   shutilt   rmtree(   t   td(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/dirtools.pyt   tempdir
   s    	c          O   sF   y t  j |  | Ž  SWn+ t k
 rA } | j t j k rB ‚  qB n Xd S(   sW   Like `mkdir`, but does not raise an exception if the
    directory already exists.
    N(   t   ost   mkdirt   OSErrort   errnot   EEXIST(   t   argst   kwargst   exc(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/dirtools.pyt   mkdir_p   s
    c         C   sß   t  j ƒ  } t j | d ƒ } xº t j |  ƒ D]© \ }  } } xL | D]D } t j j |  | ƒ } t j j | |  ƒ } | j	 | d d ƒ qD WxH | D]@ } t j j |  | ƒ } t j j | |  ƒ } | j
 | | ƒ q“ Wq. W| S(   s0   Construct an in-memory zip file for a directory.t   wt   /t    (   t   iot   BytesIOt   zipfilet   ZipFileR   t   walkt   patht   joint   relpatht   writestrt   write(   t   roott   buffert   zip_filet   dirst   filesR   t   fs_patht   rel_path(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/dirtools.pyt   dir_to_zipfile   s    (   R   R   t
   contextlibR    R   R	   R   t   contextmanagerR   R   R#   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/dirtools.pyt   <module>   s   
	