ó
1,^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 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   sixt   ordered_seti   (   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   sS  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 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.pyR0   W   s   t   linkN(    (   R   R   R3   t	   Exceptiont   setattr(   R0   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_templateR4   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   sO   t  j r t j |  ƒ n t ƒ  j ƒ  t j j d ƒ rK |  j j	 d ƒ n  d  S(   Ns   pyproject.toml(
   R   t   PY2R   t   _add_defaults_optionalt   superR   R   t   isfileR   R   (   R!   (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyRB   |   s
    	c         C   sQ   |  j  j ƒ  rM |  j d ƒ } |  j j | j ƒ  ƒ |  j |  j | ƒ ƒ n  d S(   s   getting python filest   build_pyN(   R   t   has_pure_modulesR   R   t   extendt   get_source_filest   _add_data_filest   _safe_data_files(   R!   RE   (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyt   _add_defaults_python„   s    c         C   s   |  j  j r d S| j S(   s¶   
        Extracting data_files from build_py is known to cause
        infinite recursion errors when `include_package_data`
        is enabled, so suppress it in that case.
        (    (   R   t   include_package_datat
   data_files(   R!   RE   (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyRJ   ‹   s    c         C   s   |  j  j d „  | Dƒ ƒ d S(   sA   
        Add data files as found in build_py.data_files.
        c         s   s=   |  ]3 \ } } } } | D] } t  j j | | ƒ Vq q d  S(   N(   R   R   R   (   R   R>   t   src_dirt	   filenamest   name(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pys	   <genexpr>š   s   N(   R   RG   (   R!   RM   (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyRI   •   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   RA   R   t   _add_defaults_data_filesRC   t	   TypeErrorR    t   warn(   R!   (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyRQ   Ÿ   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   existsRS   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.cfgR3   R   (   R'   R   t   make_release_treeR   R   R   t   hasattrRU   t   unlinkt	   copy_fileR   t   save_version_info(   R!   t   base_dirt   filest   dest(    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyRW   ²   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   RD   t   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'R_   s   UTF-8s"   %r not UTF-8 decodable -- skippingt   #N(   R    t   infoR`   Rc   R   t   PY3t   decodet   UnicodeDecodeErrorRS   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ñ   t  j ƒ  } |  j j d ƒ } | j d d ƒ \ } } | d k rR t j d ƒ n | j | ƒ y | j	 |  j j
 j ƒ Wn t k
 r™ t j d ƒ n Xx@ | D]8 } t j j | ƒ s¡ t j d | ƒ | j | ƒ q¡ q¡ W|  j j | ƒ d S(   sv   Checks if license_file' or 'license_files' is configured and adds any
        valid paths to 'self.filelist'.
        t   metadatat   license_files'   'license_file' option was not specifieds,   warning: 'license_files' option is malformeds8   warning: Failed to find the configured license file '%s'N(   NN(   R   t
   OrderedSetR   t   get_option_dictt   gett   NoneR    t   debugt   addt   updateRr   t   license_filesRR   RS   R   R   RU   t   removeR   RG   (   R!   R]   t   optsR>   Rs   RV   (    (    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   (    R1   R2   t   __doc__Rw   t   user_optionst   negative_optt   README_EXTENSIONSt   tupleRT   R&   R(   R)   R   t   staticmethodt
   contextlibt   contextmanagerR/   t   _sdist__read_template_hackR,   R-   t   has_leaky_handleR8   RB   RK   RJ   RI   RQ   R   RW   Rh   Rq   R~   (    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyR      sB     										
	
			
		
	(   t	   distutilsR    t   distutils.command.sdistt   commandR   R'   R   R,   Rb   R…   t   setuptools.externR   R   t
   py36compatR   R   t   listt   _default_revctrlR   (    (    (    s7   lib/python2.7/site-packages/setuptools/command/sdist.pyt   <module>   s   