ó
.¿”Wc           @   sÃ   d  d l  m  Z  d  d l m Z d  d l j j Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l m Z d  d l m Z d  d l Z d Z e Z d	 d
 „ Z d e j f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   glob(   t   logN(   t   six(   t   cs_path_existst   READMEs
   README.rsts
   README.txtt    c         c   s@   x9 t  j d ƒ D]( } x | j ƒ  |  ƒ D] } | Vq) Wq Wd S(   s%   Find all files under revision controls   setuptools.file_findersN(   t   pkg_resourcest   iter_entry_pointst   load(   t   dirnamet   ept   item(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyt   walk_revctrl   s    t   sdistc           B   sì   e  Z d  Z d d d d d f d g Z i  Z d
 „  Z d „  Z e e	 j
 d „  ƒ ƒ Z d „  Z e j d k  p« d e j k oŠ d k  n p« d e j k o© d  k  n Z e r½ e Z n  d „  Z d „  Z d „  Z d „  Z d „  Z RS(!   s=   Smart sdist that finds anything supported by revision controls   formats=s6   formats for source distribution (comma-separated list)s	   keep-tempt   ks1   keep the distribution tree around after creating s   archive file(s)s	   dist-dir=t   dsF   directory to put the source distribution archive(s) in [default: dist]c         C   s  |  j  d ƒ |  j d ƒ } | j |  _ |  j j t j j | j d ƒ ƒ |  j ƒ  x! |  j	 ƒ  D] } |  j  | ƒ qa Wd d  l
 } d | j j k r£ |  j ƒ  n  |  j ƒ  t |  j d g  ƒ } x< |  j D]1 } d d | f } | | k rÌ | j | ƒ qÌ qÌ Wd  S(   Nt   egg_infos   SOURCES.txtiÿÿÿÿt   checkt
   dist_filesR   R   (   t   run_commandt   get_finalized_commandt   filelistt   appendt   ost   patht   joinR   t   check_readmet   get_sub_commandst   distutils.commandt   commandt   __all__t   check_metadatat   make_distributiont   getattrt   distributiont   archive_files(   t   selft   ei_cmdt   cmd_namet	   distutilsR   t   filet   data(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyt   run+   s     "

c         C   s'   |  j  ƒ   t j j |  ƒ Wd QXd S(   s%   
        Workaround for #516
        N(   t   _remove_os_linkt   origR   R    (   R$   (    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyR    E   s    c          c   ss   d d d „  ƒ  Y}  t  t d |  ƒ } y
 t ` Wn t k
 rB n Xz	 d VWd | |  k	 rn t t d | ƒ n  Xd S(   sG   
        In a context, remove and restore os.link if it exists
        t   NoValuec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyR-   R   s   t   linkN(    (   R!   R   R0   t	   Exceptiont   setattr(   R-   t   orig_val(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyR+   L   s    
	c         C   s[   y t  j j |  ƒ Wn@ t k
 rV t j ƒ  \ } } } | j j j d j	 ƒ  ‚  n Xd  S(   Nt   template(
   R,   R   t   read_templateR1   t   syst   exc_infot   tb_nextt   tb_framet   f_localst   close(   R$   t   _t   tb(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyt   __read_template_hack_   s    i   i   i   i    i   i   c         C   s]  t  |  j j g } x¶ | D]® } t | t ƒ r— | } d } x4 | D], } t | ƒ rA d } |  j j | ƒ PqA qA W| sÇ |  j d d j	 | ƒ ƒ qÇ q t | ƒ r¶ |  j j | ƒ q |  j d | ƒ q Wd d g } xB | D]: } t
 t t t | ƒ ƒ ƒ } | rÞ |  j j | ƒ qÞ qÞ W|  j j ƒ  r´|  j d ƒ } |  j j | j ƒ  ƒ |  j j s´xR | j D]D \ }	 }
 }	 } |  j j g  | D] } t j j	 |
 | ƒ ^ qˆƒ qfWq´n  |  j j ƒ  rë|  j d	 ƒ } |  j j | j ƒ  ƒ n  |  j j ƒ  r"|  j d
 ƒ } |  j j | j ƒ  ƒ n  |  j j ƒ  rY|  j d ƒ } |  j j | j ƒ  ƒ n  d  S(   Ni    i   s,   standard file not found: should have one of s   , s   standard file '%s' not founds   test/test*.pys	   setup.cfgt   build_pyt	   build_extt
   build_clibt   build_scripts(   t   READMESR"   t   script_namet
   isinstancet   tupleR   R   R   t   warnR   t   listt   filterR    t   extendt   has_pure_modulesR   t   get_source_filest   include_package_datat
   data_filesR   R   t   has_ext_modulest   has_c_librariest   has_scripts(   R$   t	   standardst   fnt   altst   got_itt   optionalt   patternt   filesR?   R<   t   src_dirt	   filenamest   filenameR@   RA   RB   (    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyt   add_defaultsv   sL    	0c         C   sE   x> t  D] } t j j | ƒ r d  Sq W|  j d d j t  ƒ ƒ d  S(   Ns,   standard file not found: should have one of s   , (   RC   R   R   t   existsRG   R   (   R$   t   f(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyR   «   s    c         C   s†   t  j j |  | | ƒ t j j | d ƒ } t t d ƒ rl t j j | ƒ rl t j | ƒ |  j	 d | ƒ n  |  j
 d ƒ j | ƒ d  S(   Ns	   setup.cfgR0   R   (   R,   R   t   make_release_treeR   R   R   t   hasattrR]   t   unlinkt	   copy_fileR   t   save_version_info(   R$   t   base_dirRX   t   dest(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyR_   µ   s    !c         C   sS   t  j j |  j ƒ s t St j |  j d ƒ  } | j ƒ  } Wd  QX| d j ƒ  k S(   Nt   rbs+   # file GENERATED by distutils, do NOT edit
(	   R   R   t   isfilet   manifestt   Falset   iot   opent   readlinet   encode(   R$   t   fpt
   first_line(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyt   _manifest_is_not_generatedÂ   s    c         C   sÃ   t  j d |  j ƒ t |  j d ƒ } x | D]… } t j ry y | j d ƒ } Wqy t k
 ru t  j d | ƒ q, qy Xn  | j	 ƒ  } | j
 d ƒ s, | r¡ q, n  |  j j | ƒ q, W| j ƒ  d S(   sª   Read the manifest file (named by 'self.manifest') and use it to
        fill in 'self.filelist', the list of files to include in the source
        distribution.
        s   reading manifest file '%s'Rf   s   UTF-8s"   %r not UTF-8 decodable -- skippingt   #N(   R   t   infoRh   Rk   R   t   PY3t   decodet   UnicodeDecodeErrorRG   t   stript
   startswithR   R   R;   (   R$   Rh   t   line(    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyt   read_manifestÌ   s    	
N(   s   formats=Ns6   formats for source distribution (comma-separated list)(   s	   dist-dir=R   sF   directory to put the source distribution archive(s) in [default: dist](   i   i   i   (   i   i    (   i   i   i   (   i   i   (   i   i   i   (   R.   R/   t   __doc__t   Nonet   user_optionst   negative_optR*   R    t   staticmethodt
   contextlibt   contextmanagerR+   t   _sdist__read_template_hackR6   t   version_infot   has_leaky_handleR5   R\   R   R_   Rp   Ry   (    (    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyR      s0     						5	
		
(   R   s
   README.rsts
   README.txt(   R    R'   R   t   distutils.command.sdistR   R   R,   R   R6   Rj   R   t   setuptools.externR   t   setuptools.utilsR   R   RC   RH   t   _default_revctrlR   (    (    (    s<   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/sdist.pyt   <module>   s   