ó
b-äQc           @   si  d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l m Z d# Z d$ d% d& d' d( g Z d „  Z d d „ Z d „  Z d d „ Z d d „ Z d „  Z e	 j d e	 j ƒ Z d „  Z e d ƒ e e	 j d e	 j ƒ ƒ f e d ƒ e f e d ƒ e f e d  ƒ e f g Z d! e f d" „  ƒ  YZ d S()   iÿÿÿÿ(   t   sdist(   t   convert_path(   t   log(   t   globNt   READMEs
   README.rsts
   README.txts   &lt;t   <s   &gt;t   >s   &quot;t   "s   &apos;t   's   &amp;t   &c         C   s-   x& t  D] \ } } |  j | | ƒ }  q W|  S(   N(   t   entitiest   replace(   t   datat   oldt   new(    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   unescape   s    c            s   ‡  ‡ f d †  } | S(   Nc         3   su   t  | d ƒ } | j ƒ  } | j ƒ  xI ˆ  j | ƒ D]8 } | j d ƒ } ˆ r_ ˆ | ƒ } n  t |  | ƒ Vq5 Wd  S(   Nt   rUi   (   t   opent   readt   closet   finditert   groupt   joinpath(   t   dirnamet   filenamet   fR   t   matcht   path(   t   patternt   postproc(    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   find   s    
(    (   R   R   R   (    (   R   R   s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt	   re_finder   s    	c         C   s   |  s
 | St  j j |  | ƒ S(   N(   t   osR   t   join(   t   prefixt   suffix(    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyR       s    t    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(   R   t   ept   item(    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   walk_revctrl-   s    c         c   s¤   x t  D]• \ } } t |  | ƒ } t j j | ƒ r xe | |  | ƒ D]Q } t j j | ƒ rd | VqD t j j | ƒ rD x t | ƒ D] } | Vqƒ WqD qD Wq q Wd  S(   N(   t   findersR   R    R   t   isfilet   isdirt   _default_revctrl(   R   R   t   finderR)   (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyR.   3   s    c   	      c   s  t  } t | d ƒ } x« t | j d ƒ D]‰ } | j ƒ  } t | ƒ d k r( | \ } } | j t | ƒ ƒ } | d k rŽ | d k rŽ t } q± | d k r± | r± | j	 ƒ  Pq± q( q( W| j	 ƒ  d Sx; | j
 ƒ  D]- } | j ƒ  } | rÐ t |  | d ƒ VqÐ qÐ Wd S(	   s$   Find any 'svn:externals' directoriest   rtR$   i   t   Ks   svn:externalst   VNi    (   t   FalseR   t   itert   readlinet   splitt   lenR   t   intt   TrueR   t
   splitlinesR   (	   R   R   t   foundR   t   linet   partst   kindt   lengthR   (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   externals_finder>   s$    	

s%   name="([^"]+)"(?![^>]+deleted="true")c         c   s3  t  | d ƒ } | j ƒ  } | j ƒ  | j d ƒ rn xø t j | ƒ D]# } t |  t | j d ƒ ƒ ƒ VqD WnÁ d } y t	 | j
 ƒ  d ƒ } Wn n X| d k  rÄ t j d t j j |  ƒ ƒ d  Sxh t t j
 | j d ƒ d ƒ D]G } | sä t | ƒ d	 k r| d
 d k rqä n  t |  | d ƒ Vqä Wd  S(   NR   s   <?xmli   iÿÿÿÿi    i   s&   unrecognized .svn/entries format in %ss   

i   i   t   delete(   R   R   R   t
   startswitht   entries_patternR   R   R   R   R8   R:   R   t   warnR    R   t   abspatht   mapt   strR6   R7   (   R   R   R   R   R   t   svnvert   record(    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   entries_finderX   s$    
$  &)s   CVS/Entriess   ^\w?/([^/]+)/s   .svn/entriess   .svn/dir-propss   .svn/dir-prop-baseR    c           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  s d e j	 k oi d k  n s d e j	 k oˆ d k  n 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   appendR    R   R!   RM   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	   distutilsRO   t   fileR   (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   run   s     "

c         C   sC   y t  j |  ƒ Wn+ t j ƒ  d j j j d j ƒ  ‚  n Xd  S(   Ni   t   template(   t   _sdistt   read_templatet   syst   exc_infot   tb_nextt   tb_framet   f_localsR   (   R^   (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   __read_template_hack©   s
    !i   i   i   i    i   i   c         C   so  t  |  j j g } xÂ | D]º } t | t ƒ r | } d } x: | D]2 } t j j | ƒ rA d } |  j j	 | ƒ PqA qA W| sÓ |  j
 d d j | ƒ ƒ qÓ q t j j | ƒ rÂ |  j j	 | ƒ q |  j
 d | ƒ q Wd d g } xH | D]@ } t t t j j 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šƒ qxWqÆn  |  j j ƒ  rý|  j d	 ƒ } |  j j | j ƒ  ƒ n  |  j j ƒ  r4|  j d
 ƒ } |  j j | j ƒ  ƒ n  |  j j ƒ  rk|  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   t   existsRR   RS   RD   R!   t   listt   filterR,   R   t   extendt   has_pure_modulesRQ   t   get_source_filest   include_package_datat
   data_filest   has_ext_modulest   has_c_librariest   has_scripts(   R^   t	   standardst   fnt   altst   got_itt   optionalR   t   filesRm   t   _t   src_dirt	   filenamesR   Rn   Ro   Rp   (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   add_defaults½   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   , (   Rq   R    R   Ru   RD   R!   (   R^   R   (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyRT   ò   s
    c         C   sƒ   t  j |  | | ƒ t j j | d ƒ } t t d ƒ ri t j j | ƒ ri t j | ƒ |  j d | ƒ n  |  j	 d ƒ j
 | ƒ d  S(   Ns	   setup.cfgt   linkRM   (   Re   t   make_release_treeR    R   R!   t   hasattrRu   t   unlinkt	   copy_fileRQ   t   save_version_info(   R^   t   base_dirR…   t   dest(    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyR‹   ü   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   R,   t   manifestR3   R   R5   R   t   encode(   R^   t   fpt
   first_line(    (    s<   /usr/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 d k r y | j d ƒ } Wq t k
 r{ t  j d | ƒ q, q 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’   i   s   UTF-8s"   %r not UTF-8 decodable -- skippingt   #N(   i   (   R   t   infoR“   R   Rg   t   version_infot   decodet   UnicodeDecodeErrorRD   t   stripRB   RR   RS   R   (   R^   R“   R<   (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   read_manifest  s    
N(   s   formats=Ns6   formats for source distribution (comma-separated list)(   s	   dist-dir=RL   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_optRc   t   _sdist__read_template_hackRg   Rš   Rf   R‰   RT   R‹   R—   Rž   (    (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyR    €   s(     					5	
		(   R   s
   README.rsts
   README.txt(   s   &lt;R   (   s   &gt;R   (   s   &quot;R   (   s   &apos;R   (   s   &amp;R	   (   t   distutils.command.sdistR    Re   t   distutils.utilR   Ra   R   R   R    t   reRg   R%   Rq   R
   R   R¢   R   R   R*   R.   R@   t   compilet   IRC   RJ   t   MR+   (    (    (    s<   /usr/lib/python2.7/site-packages/setuptools/command/sdist.pyt   <module>   s,   0						