ó
¨9Vc           @   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	 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   PY3(   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-5Z5nTX/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 j	 d k  pŠ d e j	 k oi 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-5Z5nTX/setuptools/setuptools/command/sdist.pyt   run'   s     "

c         C   sQ   y t  j j |  ƒ Wn6 t j ƒ  \ } } } | j j j d j ƒ  ‚  n Xd  S(   Nt   template(	   t   origR   t   read_templatet   syst   exc_infot   tb_nextt   tb_framet   f_localst   close(   R$   t   _t   tb(    (    s<   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/sdist.pyt   __read_template_hackA   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   filesR7   R4   t   src_dirt	   filenamest   filenameR8   R9   R:   (    (    s<   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/sdist.pyt   add_defaultsX   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   , (   R;   R   R   t   existsR?   R   (   R$   t   f(    (    s<   /tmp/pip-build-5Z5nTX/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.cfgt   linkR   (   R,   R   t   make_release_treeR   R   R   t   hasattrRU   t   unlinkt	   copy_fileR   t   save_version_info(   R$   t   base_dirRP   t   dest(    (    s<   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/sdist.pyRX   —   s    !c         C   sY   t  j j |  j ƒ s t St |  j d ƒ } z | j ƒ  } Wd  | j ƒ  X| d j ƒ  k S(   Nt   rbUs+   # file GENERATED by distutils, do NOT edit
(	   R   R   t   isfilet   manifestt   Falset   opent   readlineR3   t   encode(   R$   t   fpt
   first_line(    (    s<   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/sdist.pyt   _manifest_is_not_generated¤   s    c         C   sÀ   t  j d |  j ƒ t |  j d ƒ } xŠ | D]‚ } t rv y | j d ƒ } Wqv t k
 rr t  j d | ƒ q, qv 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'R_   s   UTF-8s"   %r not UTF-8 decodable -- skippingt   #N(   R   t   infoRa   Rc   R   t   decodet   UnicodeDecodeErrorR?   t   stript
   startswithR   R   R3   (   R$   Ra   t   line(    (    s<   /tmp/pip-build-5Z5nTX/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   (   t   __name__t
   __module__t   __doc__t   Nonet   user_optionst   negative_optR*   t   _sdist__read_template_hackR.   t   version_infot   has_leaky_handleR-   RT   R   RX   Rh   Rp   (    (    (    s<   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/sdist.pyR      s*     					5	
		(   R   s
   README.rsts
   README.txt(   R    R'   R   t   distutils.command.sdistR   R   R,   R   R.   t   setuptools.compatR   t   setuptools.utilsR   R   R;   R@   t   _default_revctrlR   (    (    (    s<   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/sdist.pyt   <module>   s   