ó
%}Xc           @   s°   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 e Z d d „ Z d e e j f d	 „  ƒ  YZ d S(
   iÿÿÿÿ(   t   logN(   t   sixi   (   t   sdist_add_defaultst    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<   /usr/lib/python2.7/dist-packages/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 d „  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 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]t   READMEs
   README.rsts
   README.txtc         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<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyt   run*   s     "

c         C   s   t  j j |  ƒ |  j ƒ  d  S(   N(   t   origR   t   initialize_optionst   _default_to_gztar(   R#   (    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyR+   D   s    c         C   s#   t  j d k r d  Sd g |  _ d  S(   Ni   i   i    t   betai   t   gztar(   i   i   i    R-   i   (   t   syst   version_infot   formats(   R#   (    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyR,   I   s    c         C   s'   |  j  ƒ   t j j |  ƒ Wd QXd S(   s%   
        Workaround for #516
        N(   t   _remove_os_linkR*   R   R   (   R#   (    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyR   O   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<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyR3   ]   s   t   linkN(    (   R    R   R6   t	   Exceptiont   setattr(   R3   t   orig_val(    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyR2   V   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_templateR7   R/   t   exc_infot   tb_nextt   tb_framet   f_localst   close(   R#   t   _t   tb(    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyt   __read_template_hackk   s    i   i   i   i    i   i   c         C   sœ   |  j  j ƒ  r˜ |  j d ƒ } |  j j | j ƒ  ƒ |  j  j s˜ xR | j D]D \ } } } } |  j j g  | D] } t j	 j
 | | ƒ ^ ql ƒ qJ Wq˜ n  d S(   s   getting python filest   build_pyN(   R!   t   has_pure_modulesR   R   t   extendt   get_source_filest   include_package_datat
   data_filesR   R   R   (   R#   RD   RA   t   src_dirt	   filenamest   filename(    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyt   _add_defaults_python‚   s    c         C   sO   y* t  j r t j |  ƒ n t ƒ  j ƒ  Wn t k
 rJ t j d ƒ n Xd  S(   Ns&   data_files contains unexpected objects(   R   t   PY2R   t   _add_defaults_data_filest   supert	   TypeErrorR    t   warn(   R#   (    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyRO      s    	c         C   sK   xD |  j  D] } t j j | ƒ r
 d  Sq
 W|  j d d j |  j  ƒ ƒ d  S(   Ns,   standard file not found: should have one of s   , (   t   READMESR   R   t   existsRR   R   (   R#   t   f(    (    s<   /usr/lib/python2.7/dist-packages/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.cfgR6   R   (   R*   R   t   make_release_treeR   R   R   t   hasattrRT   t   unlinkt	   copy_fileR   t   save_version_info(   R#   t   base_dirt   filest   dest(    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyRV   £   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<   /usr/lib/python2.7/dist-packages/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'R^   s   UTF-8s"   %r not UTF-8 decodable -- skippingt   #N(   R    t   infoR`   Rc   R   t   PY3t   decodet   UnicodeDecodeErrorRR   t   stript
   startswithR   R   R@   (   R#   R`   t   line(    (    s<   /usr/lib/python2.7/dist-packages/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](   R   s
   README.rsts
   README.txt(   i   i   i   (   i   i    (   i   i   i   (   i   i   (   i   i   i   (   R4   R5   t   __doc__t   Nonet   user_optionst   negative_optRS   R)   R+   R,   R   t   staticmethodt
   contextlibt   contextmanagerR2   t   _sdist__read_template_hackR/   R0   t   has_leaky_handleR;   RM   RO   R   RV   Rh   Rq   (    (    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyR      s8     											
		
(   R&   R    t   distutils.command.sdistR   R   R*   R   R/   Rb   Rw   t   setuptools.externR   t
   py36compatR   R   t   listt   _default_revctrlR
   (    (    (    s<   /usr/lib/python2.7/dist-packages/setuptools/command/sdist.pyt   <module>   s   