ó
F—š]c           @   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(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyt   walk_revctrl   s    t   sdistc           B   s8  e  Z d  Z d# d d d d f d$ g Z i  Z d
 d d d g Z e d „  e 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 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]R   s   .rsts   .txts   .mdc         c   s   |  ] } d  j  | ƒ Vq d S(   s	   README{0}N(   t   format(   t   .0t   ext(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pys	   <genexpr>)   s    c         C   sÚ   |  j  d ƒ |  j d ƒ } | j |  _ |  j j t j j | j d ƒ ƒ |  j ƒ  x! |  j	 ƒ  D] } |  j  | ƒ qa W|  j
 ƒ  t |  j d g  ƒ } x< |  j D]1 } d d | f } | | k r¡ | j | ƒ q¡ q¡ Wd  S(   Nt   egg_infos   SOURCES.txtt
   dist_filesR   R   (   t   run_commandt   get_finalized_commandt   filelistt   appendt   ost   patht   joinR   t   check_readmet   get_sub_commandst   make_distributiont   getattrt   distributiont   archive_files(   t   selft   ei_cmdt   cmd_nameR   t   filet   data(    (    s7   lib/python2.7/site-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    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyR'   >   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    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyR(   C   s    c         C   s'   |  j  ƒ   t j j |  ƒ Wd QXd S(   s%   
        Workaround for #516
        N(   t   _remove_os_linkR&   R   R   (   R    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyR   I   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__(    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyR/   W   s   t   linkN(    (   R   R   R2   t	   Exceptiont   setattr(   R/   t   orig_val(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyR.   P   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_templateR3   R+   t   exc_infot   tb_nextt   tb_framet   f_localst   close(   R    t   _t   tb(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyt   __read_template_hacke   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    R@   R=   t   src_dirt	   filenamest   filename(    (    s7   lib/python2.7/site-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    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyRK   Š   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   existsRN   R   (   R    t   f(    (    s7   lib/python2.7/site-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.cfgR2   R   (   R&   R   t   make_release_treeR   R   R   t   hasattrRP   t   unlinkt	   copy_fileR   t   save_version_info(   R    t   base_dirt   filest   dest(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyRR      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(    (    s7   lib/python2.7/site-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'RZ   s   UTF-8s"   %r not UTF-8 decodable -- skippingt   #N(   R    t   infoR\   R_   R   t   PY3t   decodet   UnicodeDecodeErrorRN   t   stript
   startswithR   R   R<   (   R    R\   t   line(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyt   read_manifest´   s    	
c         C   s   |  j  j d ƒ } | j d d ƒ \ } } | d k rG t j d ƒ d St j j | ƒ sm t j	 d | ƒ d S|  j
 j | ƒ d S(   sy   Checks if license_file' is configured and adds it to
        'self.filelist' if the value contains a valid path.
        t   metadatat   license_files'   'license_file' option was not specifiedNs8   warning: Failed to find the configured license file '%s'(   NN(   R   t   get_option_dictt   gett   NoneR    t   debugR   R   RP   RN   R   R   (   R    t   optsR=   Ro   (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyt   check_licenseÊ   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   (   R0   R1   t   __doc__Rr   t   user_optionst   negative_optt   README_EXTENSIONSt   tupleRO   R%   R'   R(   R   t   staticmethodt
   contextlibt   contextmanagerR.   t   _sdist__read_template_hackR+   R,   t   has_leaky_handleR7   RI   RK   R   RR   Rd   Rm   Ru   (    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyR      s<     											
		
	(   t	   distutilsR    t   distutils.command.sdistt   commandR   R&   R   R+   R^   R|   t   setuptools.externR   t
   py36compatR   R   t   listt   _default_revctrlR
   (    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyt   <module>   s   