
9Vc           @   s  d  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 Z y d d l m Z Wn e k
 r n Xd d l m Z d d l m Z d d	 l m Z m Z m Z d d
 l m Z d d l m Z m Z m Z m Z m Z m Z m Z m  Z  d d l! j" Z" d d l m# Z# d e f d     YZ$ d e f d     YZ d e f d     YZ% d   Z& d   Z' d   Z( d   Z) d   Z* d   Z+ d   Z, d   Z- e. d  Z/ d   Z0 d   Z1 d S(   sU   setuptools.command.egg_info

Create a distribution's .egg-info directory and contentsi(   t   FileList(   t   convert_path(   t   logN(   t	   svn_utils(   t   Command(   t   sdist(   t
   basestringt   PY3t   StringIO(   t   walk_revctrl(   t   parse_requirementst	   safe_namet   parse_versiont   safe_versiont   yield_linest
   EntryPointt   iter_entry_pointst   to_filename(   t	   packagingt   egg_infoc           B   s   e  Z d  Z d d  d! d" d# d$ g Z d d g Z i d d 6d d 6Z d   Z d   Z d   Z e	 d  Z
 d   Z d   Z d   Z d   Z d   Z e d    Z d   Z d   Z RS(%   s+   create a distribution's .egg-info directorys	   egg-base=t   esL   directory containing .egg-info directories (default: top of the source tree)s   tag-svn-revisiont   rs,   Add subversion revision ID to version numbers   tag-datet   ds0   Add date stamp (e.g. 20050528) to version numbers
   tag-build=t   bs-   Specify explicit tag to add to version numbers   no-svn-revisiont   Rs*   Don't add subversion revision ID [default]s   no-datet   Ds"   Don't include date stamp [default]c         C   sU   d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d |  _ d |  _ t |  _	 d  |  _
 d  S(   Ni    (   t   Nonet   egg_namet   egg_versiont   egg_baseR   t	   tag_buildt   tag_svn_revisiont   tag_datet   Falset   broken_egg_infot   vtags(   t   self(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   initialize_options1   s    								c      	   C   sK   d d l  m } t d t d d d d d |  j     } | | |  d  S(   Ni(   t   edit_configR   R   i    R    R   (   t   setuptools.command.setoptR&   t   dictt   tags(   R$   t   filenameR&   t   values(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   save_version_info<   s    c         C   s  t  |  j j    |  _ |  j   |  _ |  j   |  _ t |  j  } yK t	 | t
 j j  } | ri d n d } t t | |  j |  j f   Wn3 t k
 r t j j d |  j |  j f   n X|  j d  k r|  j j } | p i  j d t j  |  _ n  |  j d  t |  j  d |  _ |  j t j k rXt j j |  j |  j  |  _ n  d |  j k rt|  j   n  |  j |  j j _ |  j j  } | d  k	 r| j! |  j j"   k r|  j | _# t |  j  | _$ d  |  j _  n  d  S(   Ns   %s==%ss   %s===%ss2   Invalid distribution name or version syntax: %s-%st    R   s	   .egg-infot   -(%   R   t   distributiont   get_nameR   R)   R#   t   tagged_versionR   R   t
   isinstanceR   t   versiont   Versiont   listR
   t
   ValueErrort	   distutilst   errorst   DistutilsOptionErrorR   R   t   package_dirt   gett   ost   curdirt   ensure_dirnameR   R   t   patht   joint   check_broken_egg_infot   metadatat   _patched_distt   keyt   lowert   _versiont   _parsed_version(   R$   t   parsed_versiont
   is_versiont   spect   dirst   pd(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   finalize_optionsH   s8    !	!!$c         C   sl   | r |  j  | | |  nL t j j |  rh | d k rX | rX t j d | |  d S|  j |  n  d S(   s  Write `data` to `filename` or delete if empty

        If `data` is non-empty, this routine is the same as ``write_file()``.
        If `data` is empty but not ``None``, this is the same as calling
        ``delete_file(filename)`.  If `data` is ``None``, then this is a no-op
        unless `filename` exists, in which case a warning is issued about the
        orphaned file (if `force` is false), or deleted (if `force` is true).
        s$   %s not set in setup(), but %s existsN(   t
   write_fileR<   R?   t   existsR   R   t   warnt   delete_file(   R$   t   whatR*   t   datat   force(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   write_or_delete_filew   s    	c         C   sa   t  j d | |  t r+ | j d  } n  |  j s] t | d  } | j |  | j   n  d S(   s   Write `data` to `filename` (if not a dry run) after announcing it

        `what` is used in a log message to identify what is being written
        to the file.
        s   writing %s to %ss   utf-8t   wbN(   R   t   infoR   t   encodet   dry_runt   opent   writet   close(   R$   RR   R*   RS   t   f(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRN      s    	c         C   s-   t  j d |  |  j s) t j |  n  d S(   s8   Delete `filename` (if not a dry run) after announcing its   deleting %sN(   R   RW   RY   R<   t   unlink(   R$   R*   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRQ      s    	c         C   sE   |  j  j   } |  j r4 | j |  j  r4 t |  St | |  j  S(   N(   R/   t   get_versionR#   t   endswithR   (   R$   R3   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR1      s    
c         C   s   |  j  |  j  |  j j } xX t d  D]J } | j d |  | j   } | |  | j t j	 j
 |  j | j   q) Wt j	 j
 |  j d  } t j	 j |  r |  j |  n  |  j   d  S(   Ns   egg_info.writerst	   installers   native_libs.txt(   t   mkpathR   R/   t   fetch_build_eggR   t   requiret   resolvet   nameR<   R?   R@   RO   RQ   t   find_sources(   R$   Ra   t   ept   writert   nl(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   run   s    ,c         C   s}   d } |  j  r | |  j  7} n  |  j rN |  j   } | rN | d | 7} qN n  |  j ry d d  l } | | j d  7} n  | S(   NR-   s   -r%sis   -%Y%m%d(   R   R   t   get_svn_revisionR    t   timet   strftime(   R$   R3   t   revRm   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR)      s    			c           C   s2   d t    k r d St t j j t j  j    S(   NR   t   0(   t   globalst   strR   t   SvnInfot   loadR<   R=   t   get_revision(    (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRl      s    c         C   sJ   t  j j |  j d  } t |  j  } | | _ | j   | j |  _ d S(   s"   Generate SOURCES.txt manifest files   SOURCES.txtN(	   R<   R?   R@   R   t   manifest_makerR/   t   manifestRk   t   filelist(   R$   t   manifest_filenamet   mm(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRg      s
    	
c         C   s   |  j  d } |  j t j k r: t j j |  j |  } n  t j j |  r t j d d d d d | |  j	  |  j	 |  _
 | |  _	 n  d  S(   Ns	   .egg-infoR.   iN   s   
Note: Your current .egg-info directory has a '-' in its name;
this will not work correctly with "setup.py develop".

Please rename %s to %s to correct this problem.
(   R   R   R<   R=   R?   R@   RO   R   RP   R   R"   (   R$   t   bei(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRA      s    (   s	   egg-base=R   sL   directory containing .egg-info directories (default: top of the source tree)(   s   tag-svn-revisionR   s,   Add subversion revision ID to version number(   s   tag-dateR   s0   Add date stamp (e.g. 20050528) to version number(   s
   tag-build=R   s-   Specify explicit tag to add to version number(   s   no-svn-revisionR   s*   Don't add subversion revision ID [default](   s   no-dateR   s"   Don't include date stamp [default](   t   __name__t
   __module__t   descriptiont   user_optionst   boolean_optionst   negative_optR%   R,   RM   R!   RU   RN   RQ   R1   Rk   R)   t   staticmethodRl   Rg   RA   (    (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR      s0     	

			/						R    c           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s@   File list that accepts only existing, platform-independent pathsc         C   sN   | j  d  r | d  } n  t |  } |  j |  rJ |  j j |  n  d  S(   Ns   i(   R`   R   t
   _safe_patht   filest   append(   R$   t   itemR?   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR      s
    c         C   s    |  j  j t |  j |   d  S(   N(   R   t   extendt   filterR   (   R$   t   paths(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR      s    c         C   s"   t  t |  j |  j   |  _ d S(   s   
        Replace self.files with only safe paths

        Because some owners of FileList manipulate the underlying
        ``files`` attribute directly, this method must be called to
        repair those paths.
        N(   R5   R   R   R   (   R$   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   _repair   s    c         C   s   d } t  j |  } | d  k r6 t j d |  t St  j | d  } | d  k rk t j | | d  t Sy, t j j	 |  s t j j	 |  r t
 SWn* t k
 r t j | | t j    n Xd  S(   Ns!   '%s' not %s encodable -- skippings'   '%s' in unexpected encoding -- skippings   utf-8(   t   unicode_utilst   filesys_decodeR   R   RP   R!   t
   try_encodeR<   R?   RO   t   Truet   UnicodeEncodeErrort   syst   getfilesystemencoding(   R$   R?   t   enc_warnt   u_patht	   utf8_path(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR      s    $(   R|   R}   t   __doc__R   R   R   R   (    (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR       s
   			
Rv   c           B   s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   s   MANIFEST.inc         C   s(   d |  _  d |  _ d |  _ d |  _ d  S(   Ni   (   t   use_defaultst   prunet   manifest_onlyt   force_manifest(   R$   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR%     s    			c         C   s   d  S(   N(    (   R$   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRM     s    c         C   s   t    |  _ t j j |  j  s. |  j   n  |  j j   |  j   t j j |  j	  rg |  j
   n  |  j   |  j j   |  j j   |  j   d  S(   N(   R    Rx   R<   R?   RO   Rw   t   write_manifestt   findallt   add_defaultst   templatet   read_templatet   prune_file_listt   sortt   remove_duplicates(   R$   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRk     s    

c         C   s"   t  j |  } | j t j d  S(   Nt   /(   R   R   t   replaceR<   t   sep(   R$   R?   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   _manifest_normalize+  s    c         C   sb   |  j  j   g  |  j  j D] } |  j |  ^ q } d |  j } |  j t |  j | f |  d S(   so   
        Write the file list in 'self.filelist' to the manifest file
        named by 'self.manifest'.
        s   writing manifest file '%s'N(   Rx   R   R   R   Rw   t   executeRN   (   R$   R]   R   t   msg(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR   /  s    (c         C   s&   | j  d  s" t j |  |  n  d  S(   Ns   standard file not found:(   t
   startswithR   RP   (   R$   R   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRP   ;  s    c         C   s   t  j |   |  j j |  j  |  j j |  j  t t    } | r[ |  j j |  n" t	 j
 j |  j  r} |  j   n  |  j d  } |  j d |  |  j j d d | j d  S(   NR   t   cmdt   *t   prefix(   R   R   Rx   R   R   Rw   R5   R	   R   R<   R?   RO   t   read_manifestt   get_finalized_commandt   _add_egg_infot   include_patternR   (   R$   t   rcfilest   ei_cmd(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR   ?  s    c            sX     j  t j k r d St j j   j   }   f d   | D } |  j j j |  d S(   s  
        Add paths for egg-info files for an external egg-base.

        The egg-info files are written to egg-base. If egg-base is
        outside the current working directory, this method
        searchs the egg-base directory for files to include
        in the manifest. Uses distutils.filelist.findall (which is
        really the version monkeypatched in by setuptools/__init__.py)
        to perform the search.

        Since findall records relative paths, prefix the returned
        paths with cmd.egg_base, so add_default's include_pattern call
        (which is looking for the absolute cmd.egg_info) will match
        them.
        Nc         3   s'   |  ] } t  j j   j |  Vq d  S(   N(   R<   R?   R@   R   (   t   .0R?   (   R   (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pys	   <genexpr>a  s    (   R   R<   R=   R7   Rx   R   t   allfilesR   (   R$   R   t
   discoveredt   resolved(    (   R   s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR   L  s
    c         C   s   |  j  d  } |  j j   } |  j j d  d | j |  j j d  d | t j t	 j
  } |  j j d | d | d d d  S(   Nt   buildR   s   (^|s   )(RCS|CVS|\.svn)t   is_regexi   (   R   R/   t   get_fullnameRx   t   exclude_patternR   t
   build_baset   ret   escapeR<   R   (   R$   R   t   base_dirR   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR   d  s    (   R|   R}   R   R%   RM   Rk   R   R   RP   R   R   R   (    (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRv     s   								c         C   sG   d j  |  } | j d  } t |  d   } | j |  Wd QXd S(   s{   Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    s   
s   utf-8RV   N(   R@   RX   RZ   R[   (   R*   t   contentsR]   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyRN   n  s    c         C   s   t  j d |  |  j s |  j j } |  j | j | _ } |  j | j | _ } z | j	 |  j
  Wd  | | | _ | _ Xt |  j d d   } d d l m } | j |  j
 |  n  d  S(   Ns
   writing %st   zip_safei(   t	   bdist_egg(   R   RW   RY   R/   RB   R   R3   R   Rf   t   write_pkg_infoR   t   getattrR   t   setuptools.commandR   t   write_safety_flag(   R   t   basenameR*   RB   t   oldvert   oldnamet   safeR   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR   {  s    	c         C   s&   t  j j |  r" t j d  n  d  S(   Nss   WARNING: 'depends.txt' is not used by setuptools 0.6!
Use the install_requires/extras_require setup() args instead.(   R<   R?   RO   R   RP   (   R   R   R*   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   warn_depends_obsolete  s    c         C   s;   t  | p d  } d   } t | |  } |  j |  d  S(   Nc         S   s   |  d S(   Ns   
(    (   t   line(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   <lambda>  s    (    (   R   t   mapt
   writelines(   t   streamt   reqst   linest	   append_cr(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   _write_requirements  s    	c         C   s   |  j  } t   } t | | j  | j p. i  } x> t |  D]0 } | j d j t      t | | |  q> W|  j	 d | | j
    d  S(   Ns   
[{extra}]
t   requirements(   R/   R   R   t   install_requirest   extras_requiret   sortedR[   t   formatt   varsRU   t   getvalue(   R   R   R*   t   distRS   R   t   extra(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   write_requirements  s    		c         C   s9   t    } t | |  j j  |  j d | | j    d  S(   Ns   setup-requirements(   R   R   R/   t   setup_requiresRU   R   (   R   R   R*   RS   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   write_setup_requirements  s    	c         C   se   t  j g  |  j j   D] } | j d d  d ^ q  } |  j d | d j t |   d  d  S(   Nt   .i   i    s   top-level namess   
(   R(   t   fromkeysR/   t   iter_distribution_namest   splitRN   R@   R   (   R   R   R*   t   kt   pkgs(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   write_toplevel_names  s    2c         C   s   t  |  | | t  d  S(   N(   t	   write_argR   (   R   R   R*   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   overwrite_arg  s    c         C   sg   t  j j |  d } t |  j | d   } | d  k	 rM d j |  d } n  |  j | | | |  d  S(   Ni    s   
(   R<   R?   t   splitextR   R/   R   R@   RU   (   R   R   R*   RT   t   argnamet   value(    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyR     s
    c         C   s   |  j  j } t | t  s' | d  k r0 | } n | d  k	 r g  } x t | j    D]k \ } } t | t  s t j | |  } d j	 t t
 t | j      } n  | j d | | f  qU Wd j	 |  } n  |  j d | | t  d  S(   Ns   
s	   [%s]
%s

R-   s   entry points(   R/   t   entry_pointsR2   R   R   R   t   itemsR   t   parse_groupR@   R   Rr   R+   R   RU   R   (   R   R   R*   Rh   RS   t   sectionR   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   write_entries  s    	'c          C   sn   t  j j d  rj t d d  }  x9 |  D]1 } t j d |  } | r( t | j d   Sq( W|  j   n  d S(   Ns   PKG-INFOt   rUs   Version:.*-r(\d+)\s*$i   i    (	   R<   R?   RO   RZ   R   t   matcht   intt   groupR\   (   R]   R   R   (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   get_pkg_info_revision  s    (2   R   t   distutils.filelistR    t	   _FileListt   distutils.utilR   R7   R   t   distutils.errorsR<   R   R   t   setuptools_svnR   t   ImportErrort
   setuptoolsR   t   setuptools.command.sdistR   t   setuptools.compatR   R   R   R	   t   pkg_resourcesR
   R   R   R   R   R   R   R   t   setuptools.unicode_utilsR   R   R   Rv   RN   R   R   R   R   R   R   R   R!   R   R   R   (    (    (    s?   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/egg_info.pyt   <module>   sB   :0\							
		