î
½1kdð7  ã               @   s¥  d  Z  d d l Z d d l Z d d l Z d d l m Z d d l Z d d l m Z d d l	 m
 Z
 d d l m Z d d l m Z d d l 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	 m Z Gd d „  d e ƒ Z Gd d „  d e ƒ Z Gd d „  d e
 ƒ Z d d „  Z d d „  Z  d d „  Z! d d „  Z" d d „  Z# d d „  Z$ d d d  „ Z% d! d" „  Z& d# d$ „  Z' d S)%zUsetuptools.command.egg_info

Create a distribution's .egg-info directory and contentsé    N)ÚCommand)Úlog)Úsdist)Ú
basestring)Ú	svn_utils)Úconvert_path)ÚFileList)Úparse_requirementsÚ	safe_nameÚparse_versionÚsafe_versionÚyield_linesÚ
EntryPointÚiter_entry_pointsÚto_filename)Úwalk_revctrlc               @   sç   e  Z d  Z d Z d. d/ d0 d1 d2 d3 g Z d d g Z i d d 6d d 6Z d d „  Z d d „  Z d d „  Z	 d d d „ Z
 d d „  Z d d  „  Z d! d" „  Z d# d$ „  Z d% d& „  Z e d' d( „  ƒ Z d) d* „  Z d+ d, „  Z d- S)4Úegg_infoz+create a distribution's .egg-info directoryú	egg-base=ÚeúLdirectory containing .egg-info directories (default: top of the source tree)útag-svn-revisionÚrú,Add subversion revision ID to version numberútag-dateÚdú0Add date stamp (e.g. 20050528) to version numberú
tag-build=Úbú-Specify explicit tag to add to version numberúno-svn-revisionÚRú*Don't add subversion revision ID [default]úno-dateÚDú"Don't include date stamp [default]c             C   sU   d  |  _  d  |  _ d  |  _ d  |  _ d  |  _ d |  _ d |  _ d |  _ d  |  _ d  S)Nr   F)	Úegg_nameÚegg_versionÚegg_baser   Ú	tag_buildÚtag_svn_revisionÚtag_dateÚbroken_egg_infoÚvtags)Úself© r.   úQ/var/www/pythonscrapper/code/venv/build/setuptools/setuptools/command/egg_info.pyÚinitialize_options)   s    								zegg_info.initialize_optionsc          	   C   sK   d d l  m } t d t d d d d d |  j ƒ  ƒ ƒ } | | | ƒ d  S)Nr   )Úedit_configr   r)   r*   r(   )Zsetuptools.command.setoptr1   ÚdictÚtags)r-   Úfilenamer1   Úvaluesr.   r.   r/   Úsave_version_info4   s    zegg_info.save_version_infoc             C   s²  t  |  j j ƒ  ƒ |  _ |  j ƒ  |  _ |  j ƒ  |  _ y$ t t	 d |  j |  j f ƒ ƒ Wn4 t
 k
 r� t j j d |  j |  j f ƒ ‚ Yn X|  j d  k rÍ |  j j } | pµ i  j d t j ƒ |  _ n  |  j d ƒ t |  j ƒ d |  _ |  j t j k r#t j j |  j |  j ƒ |  _ n  d |  j k r?|  j ƒ  n  |  j |  j j _ |  j j } | d  k	 r®| j |  j j ƒ  k r®|  j | _ t |  j ƒ | _  d  |  j _ n  d  S)Nz%s==%sz2Invalid distribution name or version syntax: %s-%sÚ r'   z	.egg-infoú-)!r
   ÚdistributionÚget_namer%   r3   r,   Útagged_versionr&   Úlistr	   Ú
ValueErrorÚ	distutilsÚerrorsÚDistutilsOptionErrorr'   Úpackage_dirÚgetÚosÚcurdirÚensure_dirnamer   r   ÚpathÚjoinÚcheck_broken_egg_infoÚmetadataÚversionZ_patched_distÚkeyÚlowerÚ_versionr   Ú_parsed_version)r-   ÚdirsÚpdr.   r.   r/   Úfinalize_options?   s2    !	!! $zegg_info.finalize_optionsFc             C   sl   | r |  j  | | | ƒ nL t j j | ƒ rh | d k rX | rX t j d | | ƒ d S|  j | ƒ n  d S)a¹  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).
        Nz$%s not set in setup(), but %s exists)Ú
write_filerC   rF   Úexistsr   ÚwarnÚdelete_file)r-   Úwhatr4   ÚdataÚforcer.   r.   r/   Úwrite_or_delete_fileg   s    	zegg_info.write_or_delete_filec             C   sj   t  j d | | ƒ t j d k r4 | j d ƒ } n  |  j sf t | d ƒ } | j | ƒ | j ƒ  n  d S)zª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.
        zwriting %s to %sé   zutf-8ÚwbN)rZ   )	r   ÚinfoÚsysÚversion_infoÚencodeÚdry_runÚopenÚwriteÚclose)r-   rV   r4   rW   Úfr.   r.   r/   rR   {   s    	zegg_info.write_filec             C   s-   t  j d | ƒ |  j s) t j | ƒ n  d S)z8Delete `filename` (if not a dry run) after announcing itzdeleting %sN)r   r\   r`   rC   Úunlink)r-   r4   r.   r.   r/   rU   ‰   s    	zegg_info.delete_filec             C   sE   |  j  j ƒ  } |  j r4 | j |  j ƒ r4 t | ƒ St | |  j ƒ S)N)r9   Úget_versionr,   Úendswithr   )r-   rJ   r.   r.   r/   r;   �   s    
zegg_info.tagged_versionc             C   sµ   |  j  |  j ƒ |  j j } xN t d ƒ D]@ } | j d | ƒ } | |  | j t j j	 |  j | j ƒ ƒ q) Wt j j	 |  j d ƒ } t j j
 | ƒ r§ |  j | ƒ n  |  j ƒ  d  S)Nzegg_info.writersÚ	installerznative_libs.txt)Úmkpathr   r9   Zfetch_build_eggr   ÚloadÚnamerC   rF   rG   rS   rU   Úfind_sources)r-   rh   ÚepÚwriterÚnlr.   r.   r/   Úrun—   s    ,zegg_info.runc             C   s’   d } |  j  r | |  j  7} n  |  j rc t j j d ƒ sL t j j d ƒ rc | d |  j ƒ  7} n  |  j rŽ d d  l } | | j d ƒ 7} n  | S)Nr7   z.svnzPKG-INFOz-r%sr   z-%Y%m%d)	r(   r)   rC   rF   rS   Úget_svn_revisionr*   ÚtimeÚstrftime)r-   rJ   rr   r.   r.   r/   r3   ¥   s    		$	zegg_info.tagsc               C   s   t  t j j t j ƒ j ƒ  ƒ S)N)Ústrr   ZSvnInforj   rC   rD   Úget_revisionr.   r.   r.   r/   rq   ±   s    zegg_info.get_svn_revisionc             C   sJ   t  j j |  j d ƒ } t |  j ƒ } | | _ | j ƒ  | j |  _ d S)z"Generate SOURCES.txt manifest filezSOURCES.txtN)	rC   rF   rG   r   Úmanifest_makerr9   Úmanifestrp   Úfilelist)r-   Zmanifest_filenameÚmmr.   r.   r/   rl   µ   s
    	
zegg_info.find_sourcesc             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)Nz	.egg-infor8   éN   z¦
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'   rC   rD   rF   rG   rS   r   rT   r   r+   )r-   Zbeir.   r.   r/   rH   ½   s    zegg_info.check_broken_egg_infoN)r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r    r!   )r"   r#   r$   )Ú__name__Ú
__module__Ú__qualname__ÚdescriptionÚuser_optionsÚboolean_optionsÚnegative_optr0   r6   rQ   rY   rR   rU   r;   rp   r3   Ústaticmethodrq   rl   rH   r.   r.   r.   r/   r      s0     	

(r   c               @   s"   e  Z d  Z d Z d d „  Z d S)r   z@File list that accepts only existing, platform-independent pathsc             C   s	  | j  d ƒ r" | d  d … } n  t | ƒ } t j d k rà yD t j j | ƒ sm t j j | j d ƒ ƒ r€ |  j j	 | ƒ n  Wqt
 k
 rÜ t j j | j d ƒ ƒ r¿ |  j j	 | ƒ n t j d | t j ƒ  ƒ YqXn% t j j | ƒ r|  j j	 | ƒ n  d  S)Núé   rZ   zutf-8z!'%s' not %s encodable -- skippingéÿÿÿÿ)rZ   )rg   r   r]   r^   rC   rF   rS   r_   ÚfilesÚappendÚUnicodeEncodeErrorr   rT   Úgetfilesystemencoding)r-   ÚitemrF   r.   r.   r/   r‡   Ï   s    -zFileList.appendN)r{   r|   r}   Ú__doc__r‡   r.   r.   r.   r/   r   Ì   s   r   c               @   sj   e  Z d  Z d Z d d „  Z d d „  Z d d „  Z d d	 „  Z d
 d „  Z d d „  Z	 d d „  Z
 d S)rv   zMANIFEST.inc             C   s(   d |  _  d |  _ d |  _ d |  _ d  S)Nr„   )Zuse_defaultsZpruneZmanifest_onlyZforce_manifest)r-   r.   r.   r/   r0   è   s    			z!manifest_maker.initialize_optionsc             C   s   d  S)Nr.   )r-   r.   r.   r/   rQ   î   s    zmanifest_maker.finalize_optionsc             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   rC   rF   rS   rw   Úwrite_manifestÚfindallÚadd_defaultsÚtemplateZread_templateÚprune_file_listÚsortZremove_duplicates)r-   r.   r.   r/   rp   ñ   s    

zmanifest_maker.runc             C   s×   t  j d	 k r g  } xX |  j j D]J } y | j d ƒ Wn# t k
 r^ t j d | ƒ Yq" X| j | ƒ q" W| |  j _ n  |  j j } t	 j
 d k r° d d „  | Dƒ } n  |  j t |  j | f d |  j ƒ d S)
z²Write the file list in 'self.filelist' (presumably as filled in
        by 'add_defaults()' and 'read_template()') to the manifest file
        named by 'self.manifest'.
        rZ   zutf-8z$'%s' not UTF-8 encodable -- skippingú/c             S   s%   g  |  ] } | j  t j d  ƒ ‘ q S)r’   )ÚreplacerC   Úsep)Ú.0rd   r.   r.   r/   ú
<listcomp>  s   	 z1manifest_maker.write_manifest.<locals>.<listcomp>zwriting manifest file '%s'N)rZ   )r]   r^   rx   r†   r_   rˆ   r   rT   r‡   rC   r”   ÚexecuterR   rw   )r-   r†   Úfiler.   r.   r/   rŒ   þ   s    zmanifest_maker.write_manifestc             C   s&   | j  d ƒ s" t j |  | ƒ n  d  S)Nzstandard file not found:)Ú
startswithr   rT   )r-   Úmsgr.   r.   r/   rT     s    zmanifest_maker.warnc             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 j d d | j ƒd  S)Nr   Ú*Úprefix)r   rŽ   rx   r‡   r�   rw   r<   r   ÚextendrC   rF   rS   Zread_manifestÚget_finalized_commandZinclude_patternr   )r-   ZrcfilesZei_cmdr.   r.   r/   rŽ     s    zmanifest_maker.add_defaultsc             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  S)NÚbuildrœ   z(RCS|CVS|\.svn)Zis_regexr„   )
rž   r9   Úget_fullnamerx   Zexclude_patternÚ
build_baseÚreÚescaperC   r”   )r-   rŸ   Úbase_dirr”   r.   r.   r/   r�   %  s    zmanifest_maker.prune_file_listN)r{   r|   r}   r�   r0   rQ   rp   rŒ   rT   rŽ   r�   r.   r.   r.   r/   rv   ä   s   rv   c             C   sZ   d j  | ƒ } t j d k r0 | j d ƒ } n  t |  d ƒ } | j | ƒ | j ƒ  d S)z{Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    Ú
rZ   zutf-8r[   N)rZ   )rG   r]   r^   r_   ra   rb   rc   )r4   Úcontentsrd   r.   r.   r/   rR   .  s    rR   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)Nz
writing %sZzip_safer   )Ú	bdist_egg)r   r\   r`   r9   rI   r&   rJ   r%   rk   Úwrite_pkg_infor   ÚgetattrZsetuptools.commandr§   Zwrite_safety_flag)ÚcmdÚbasenamer4   rI   ZoldverZoldnameÚsafer§   r.   r.   r/   r¨   9  s    	r¨   c             C   s&   t  j j | ƒ r" t j d ƒ n  d  S)NzsWARNING: 'depends.txt' is not used by setuptools 0.6!
Use the install_requires/extras_require setup() args instead.)rC   rF   rS   r   rT   )rª   r«   r4   r.   r.   r/   Úwarn_depends_obsoleteJ  s    r­   c             C   s–   |  j  } d j t | j p f  ƒ ƒ g } xI | j p9 i  j ƒ  D]2 \ } } | j d | d j t | ƒ ƒ f ƒ q@ W|  j d | d j | ƒ ƒ d  S)Nr¥   z	

[%s]
%sÚrequirementsr7   )r9   rG   r   Zinstall_requiresZextras_requireÚitemsr‡   rY   )rª   r«   r4   ÚdistrW   ÚextraÚreqsr.   r.   r/   Úwrite_requirementsR  s
    	!"*r³   c             C   sI   t  j d d „  |  j j ƒ  Dƒ ƒ } |  j d | d j | ƒ d ƒ d  S)Nc             S   s&   g  |  ] } | j  d  d ƒ d ‘ q S)Ú.r„   r   )Úsplit)r•   Úkr.   r.   r/   r–   \  s   	z(write_toplevel_names.<locals>.<listcomp>ztop-level namesr¥   )r2   Úfromkeysr9   Ziter_distribution_namesrR   rG   )rª   r«   r4   Úpkgsr.   r.   r/   Úwrite_toplevel_namesY  s    	r¹   c             C   s   t  |  | | d ƒ d  S)NT)Ú	write_arg)rª   r«   r4   r.   r.   r/   Úoverwrite_argc  s    r»   Fc             C   sg   t  j j | ƒ d } t |  j | d  ƒ } | d  k	 rM d j | ƒ d } n  |  j | | | | ƒ d  S)Nr   r¥   )rC   rF   Úsplitextr©   r9   rG   rY   )rª   r«   r4   rX   ZargnameÚvaluer.   r.   r/   rº   f  s
    rº   c             C   sä   |  j  j } t | t ƒ s' | d  k r0 | } nš | d  k	 rÊ g  } xs | j ƒ  D]e \ } } t | t ƒ s� t j | | ƒ } d j t t	 | j
 ƒ  ƒ ƒ } n  | j d | | f ƒ qO Wd j | ƒ } n  |  j d | | d ƒ d  S)Nr¥   z	[%s]
%s

r7   zentry pointsT)r9   Zentry_pointsÚ
isinstancer   r¯   r   Úparse_grouprG   Úmaprt   r5   r‡   rY   )rª   r«   r4   rm   rW   Úsectionr¦   r.   r.   r/   Úwrite_entriesm  s    	!rÂ   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)NzPKG-INFOÚrUzVersion:.*-r(\d+)\s*$r„   r   )	rC   rF   rS   ra   r¢   ÚmatchÚintÚgrouprc   )rd   ÚlinerÄ   r.   r.   r/   Úget_pkg_info_revision}  s    rÈ   )(r‹   rC   r¢   r]   Ú
setuptoolsr   Zdistutils.errorsr>   r   Zsetuptools.command.sdistr   Zsetuptools.compatr   r   Údistutils.utilr   Údistutils.filelistr   Z	_FileListÚpkg_resourcesr	   r
   r   r   r   r   r   r   r   r   rv   rR   r¨   r­   r³   r¹   r»   rº   rÂ   rÈ   r.   r.   r.   r/   Ú<module>   s2   :¶J
