a
    ´iÑÄ  ã                   @   sÆ   d dl Z d dlZd dlZd dlmZ zd dlZW n eyF   dZY n0 d dlT d dlm	Z	m
Z
 d dlmZmZmZ d dlmZ d dlmZ e d¡Zd	d
„ ZG dd„ dƒZG dd„ dƒZdd„ ZdS )é    N)Úmessage_from_file)Ú*)ÚFancyGetoptÚtranslate_longopt)Úcheck_environÚ	strtoboolÚrfc822_escape©Úlog)ÚDEBUGz^[a-zA-Z]([a-zA-Z0-9_]*)$c                 C   sL   t | tƒrn<t | tƒsHt| ƒj}d|› d|› d�}t tj|¡ t| ƒ} | S )Nz
Warning: 'z' should be a list, got type 'ú')Ú
isinstanceÚstrÚlistÚtypeÚ__name__r
   ÚWARN)ÚvalueÚ	fieldnameÚtypenameÚmsg© r   ú&/usr/lib64/python3.9/distutils/dist.pyÚ_ensure_list   s    


r   c                   @   s@  e Zd Zg d¢ZdZg d¢Zdd„ eD ƒZddiZdHd	d
„Zdd„ Z	dIdd„Z
dd„ ZdJdd„Zdd„ Zdd„ Zdd„ Zdd„ Zddg fdd„Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ ZdKd+d,„ZdLd-d.„ZdMd0d1„Zejfd2d3„Zd4d5„ Zd6d7„ Zd8d9„ Z d:d;„ Z!d<d=„ Z"d>d?„ Z#d@dA„ Z$dBdC„ Z%dDdE„ Z&dFdG„ Z'dS )NÚDistribution))ÚverboseÚvzrun verbosely (default)é   )ÚquietÚqz!run quietly (turns verbosity off))zdry-runÚnzdon't actually do anything)ÚhelpÚhzshow detailed help message)zno-user-cfgNz-ignore pydistutils.cfg in your home directoryz£Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package
))zhelp-commandsNzlist all available commands)ÚnameNzprint package name)ÚversionÚVzprint package version)ÚfullnameNzprint <package name>-<version>)ÚauthorNzprint the author's name)úauthor-emailNz print the author's email address)Ú
maintainerNzprint the maintainer's name)zmaintainer-emailNz$print the maintainer's email address)ÚcontactNz7print the maintainer's name if known, else the author's)zcontact-emailNz@print the maintainer's email address if known, else the author's)ÚurlNzprint the URL for this package)ÚlicenseNz print the license of the package)ÚlicenceNzalias for --license)ÚdescriptionNzprint the package description)zlong-descriptionNz"print the long package description)Ú	platformsNzprint the list of platforms)ÚclassifiersNzprint the list of classifiers)ÚkeywordsNzprint the list of keywords)ÚprovidesNz+print the list of packages/modules provided)ÚrequiresNz+print the list of packages/modules required)Ú	obsoletesNz0print the list of packages/modules made obsoletec                 C   s   g | ]}t |d  ƒ‘qS )r   ©r   )Ú.0Úxr   r   r   Ú
<listcomp>�   ó    zDistribution.<listcomp>r   r   Nc                 C   s\  d| _ d| _d| _| jD ]}t| |dƒ qtƒ | _| jjD ] }d| }t| |t| j|ƒƒ q:i | _	d | _
d | _d | _i | _g | _d | _i | _d | _d | _d | _d | _d | _d | _d | _d | _d | _d | _d| _i | _i | _|�r| d¡}|d u�r8|d= | ¡ D ]4\}}|   |¡}| ¡ D ]\}	}
d|
f||	< �q�qd|v �r~|d |d< |d= d	}t!d u�rnt! "|¡ nt#j$ %|d
 ¡ | ¡ D ]€\}}
t&| jd| ƒ�r¶t| jd| ƒ|
ƒ nNt&| j|ƒ�rÔt| j||
ƒ n0t&| |ƒ�rît| ||
ƒ ndt'|ƒ }t! "|¡ �q†d| _(| jd u�rP| jD ].}| )d¡�s6 �qP|dk�r d| _( �qP�q |  *¡  d S )Nr   r   Úget_Ú Úoptionszsetup scriptr-   r,   z:'licence' distribution option is deprecated; use 'license'Ú
Zset_zUnknown distribution option: %sTú-z--no-user-cfgF)+r   Údry_runr!   Údisplay_option_namesÚsetattrÚDistributionMetadataÚmetadataÚ_METHOD_BASENAMESÚgetattrÚcmdclassÚcommand_packagesÚscript_nameÚscript_argsÚcommand_optionsZ
dist_filesÚpackagesZpackage_dataZpackage_dirÚ
py_modulesÚ	librariesÚheadersÚext_modulesZext_packageZinclude_dirsZ
extra_pathÚscriptsÚ
data_filesÚpasswordÚcommand_objÚhave_runÚgetÚitemsÚget_option_dictÚwarningsÚwarnÚsysÚstderrÚwriteÚhasattrÚreprÚwant_user_cfgÚ
startswithÚfinalize_options)ÚselfÚattrsÚattrÚbasenameZmethod_namer<   ÚcommandZcmd_optionsÚopt_dictÚoptÚvalr   ÚkeyÚargr   r   r   Ú__init__ˆ   s~    








zDistribution.__init__c                 C   s&   | j  |¡}|d u r"i  }| j |< |S ©N)rJ   rU   )rb   rf   Údictr   r   r   rW   &  s    zDistribution.get_option_dictr;   c           	      C   sÈ   ddl m} |d u r"t| j ¡ ƒ}|d ur@|  || ¡ |d }|sV|  |d ¡ d S |D ]h}| j |¡}|d u r†|  |d|  ¡ qZ|  |d|  ¡ ||ƒ}| d¡D ]}|  |d | ¡ qªqZd S )Nr   )Úpformatz  zno commands known yetzno option dict for '%s' commandzoption dict for '%s' command:r=   )Zpprintro   ÚsortedrJ   ÚkeysÚannouncerU   Úsplit)	rb   ÚheaderÚcommandsÚindentro   Zcmd_namerg   ÚoutÚliner   r   r   Údump_option_dicts1  s*    ÿÿzDistribution.dump_option_dictsc                 C   s¾   g }t ƒ  tj tjd j¡}tj |d¡}tj |¡rB| 	|¡ tj
dkrRd}nd}| jrˆtj tj d¡|¡}tj |¡rˆ| 	|¡ d}tj |¡r¢| 	|¡ trº|  dd	 |¡ ¡ |S )
NÚ	distutilszdistutils.cfgÚposixz.pydistutils.cfgzpydistutils.cfgú~z	setup.cfgzusing config files: %sz, )r   ÚosÚpathÚdirnamerZ   ÚmodulesÚ__file__ÚjoinÚisfileÚappendr#   r_   Ú
expanduserr   rr   )rb   ÚfilesZsys_dirZsys_fileZuser_filenameZ	user_fileZ
local_filer   r   r   Úfind_config_filesM  s&    



zDistribution.find_config_filesc                 C   sŽ  ddl m} tjtjkr"g d¢}ng }t|ƒ}|d u r>|  ¡ }trL|  d¡ |ƒ }|D ]ˆ}trl|  d| ¡ | 	|¡ | 
¡ D ]V}| |¡}|  |¡}|D ]8}	|	dkrš|	|vrš| ||	¡}
|	 dd¡}	||
f||	< qšq~| ¡  qVd	| jv �rŠ| jd	  ¡ D ]Ž\}	\}}
| j |	¡}zF|�r.t| |t|
ƒ ƒ n(|	d
v �rJt| |	t|
ƒƒ nt| |	|
ƒ W qú t�y† } zt|ƒ‚W Y d }~qúd }~0 0 qúd S )Nr   )ÚConfigParser)zinstall-basezinstall-platbasezinstall-libzinstall-platlibzinstall-purelibzinstall-headerszinstall-scriptszinstall-dataÚprefixzexec-prefixÚhomeÚuserÚrootz"Distribution.parse_config_files():z  reading %sr   r>   Ú_Úglobal)r   r?   )Úconfigparserrˆ   rZ   r‰   Úbase_prefixÚ	frozensetr‡   r   rr   ÚreadZsectionsr<   rW   rU   Úreplacerl   rJ   rV   Únegative_optrA   r   Ú
ValueErrorÚDistutilsOptionError)rb   Ú	filenamesrˆ   Zignore_optionsÚparserÚfilenameÚsectionr<   rg   rh   ri   ÚsrcÚaliasr   r   r   r   Úparse_config_files}  sD    






zDistribution.parse_config_filesc                 C   s¾   |   ¡ }g | _t|| j ƒ}| | j¡ | ddi¡ |j| j| d�}| 	¡ }t
 | j¡ |  |¡rhd S |r†|  ||¡}|d u rhd S qh| jr¬| j|t| jƒdk| jd� d S | jsºtdƒ‚dS )Nr-   r,   )ÚargsÚobjectr   ©Údisplay_optionsru   zno commands suppliedT)Ú_get_toplevel_optionsru   r   r¡   Úset_negative_aliasesr”   Zset_aliasesÚgetoptrI   Zget_option_orderr
   Zset_verbosityr   Úhandle_display_optionsÚ_parse_command_optsr!   Ú
_show_helpÚlenÚDistutilsArgError)rb   Ztoplevel_optionsr˜   rž   Úoption_orderr   r   r   Úparse_command_line·  s.    	
þzDistribution.parse_command_linec                 C   s   | j dg S )N)zcommand-packages=Nz0list of packages that provide distutils commands)Úglobal_options©rb   r   r   r   r¢   ú  s    ÿz"Distribution._get_toplevel_optionsc              
   C   s   ddl m} |d }t |¡s*td| ƒ‚| j |¡ z|  |¡}W n, typ } zt	|ƒ‚W Y d }~n
d }~0 0 t
||ƒsˆtd| ƒ‚t|dƒržt|jtƒs®d}t|| ƒ‚| j}t|dƒrÒ| ¡ }| |j¡ t|dƒrôt|jtƒrôt|jƒ}ng }| | j|j | ¡ | |¡ | |d	d … ¡\}}	t|	d
ƒ�rX|	j�rX| j|d|gd� d S t|dƒ�rÎt|jtƒ�rÎd}
|jD ]F\}}}}t|	| |¡ƒ�r|d	}
t|ƒ�r°|ƒ  ntd||f ƒ‚�q||
�rÎd S |  |¡}t|	ƒ ¡ D ]\}}d|f||< �qä|S )Nr   ©ÚCommandzinvalid command name '%s'z&command class %s must subclass CommandÚuser_optionszIcommand class %s must provide 'user_options' attribute (a list of tuples)r”   Úhelp_optionsr   r!   r    zYinvalid help function %r for help option '%s': must be a callable object (function, etc.)zcommand line) Údistutils.cmdr¯   Ú
command_reÚmatchÚ
SystemExitru   r„   Úget_command_classÚDistutilsModuleErrorr©   Ú
issubclassZDistutilsClassErrorr]   r   r°   r   r”   ÚcopyÚupdater±   Úfix_help_optionsÚset_option_tabler¬   r£   r¤   r!   r§   Zget_attr_nameÚcallablerW   ÚvarsrV   )rb   r˜   rž   r¯   rf   Z	cmd_classr   r”   r±   ZoptsZhelp_option_foundZhelp_optionZshortZdescÚfuncrg   r#   r   r   r   r   r¦     sr    


ÿ

ÿ


ÿÿþ

ÿ
þÿ
z Distribution._parse_command_optsc                 C   sP   dD ]F}t | j|ƒ}|d u rqt|tƒrdd„ | d¡D ƒ}t| j||ƒ qd S )N©r1   r/   c                 S   s   g | ]}|  ¡ ‘qS r   ©Ústrip)r6   Zelmr   r   r   r8   j  r9   z1Distribution.finalize_options.<locals>.<listcomp>ú,)rE   rC   r   r   rs   rA   )rb   rd   r   r   r   r   ra   `  s    
zDistribution.finalize_optionsr   c           
      C   s  ddl m} ddlm} |rR|r*|  ¡ }n| j}| |¡ | | jd ¡ t	dƒ |rt| | j
¡ | d¡ t	dƒ | jD ]z}t|tƒr˜t||ƒr˜|}	n
|  |¡}	t|	dƒrÐt|	jtƒrÐ| |	jt|	jƒ ¡ n| |	j¡ | d|	j ¡ t	dƒ qzt	|| jƒƒ d S )	Nr   ©Ú	gen_usager®   z
Global options:r;   zKInformation display options (just display information, ignore any commands)r±   zOptions for '%s' command:)Údistutils.corerÅ   r²   r¯   r¢   r¬   r¼   Ú
print_helpÚcommon_usageÚprintr¡   ru   r   r   r¸   r¶   r]   r±   r   r°   r»   r   rH   )
rb   r˜   r¬   r¡   ru   rÅ   r¯   r<   rf   Úklassr   r   r   r§   m  s:    

ÿ



ÿÿ
zDistribution._show_helpc           	      C   sÊ   ddl m} | jr4|  ¡  tdƒ t|| jƒƒ dS d}i }| jD ]}d||d < qB|D ]l\}}|rX| |¡rXt|ƒ}t	| j
d| ƒƒ }|dv r td |¡ƒ n |dv r¸td	 |¡ƒ nt|ƒ d}qX|S )
Nr   rÄ   r;   r   r:   rÀ   rÃ   )r0   r2   r3   r4   r=   )rÆ   rÅ   Zhelp_commandsÚprint_commandsrÉ   rH   r¡   rU   r   rE   rC   r‚   )	rb   rª   rÅ   Zany_display_optionsZis_display_optionÚoptionrh   ri   r   r   r   r   r¥   Ÿ  s*    
z#Distribution.handle_display_optionsc              	   C   sh   t |d ƒ |D ]R}| j |¡}|s.|  |¡}z
|j}W n tyN   d}Y n0 t d|||f ƒ qd S )Nú:ú(no description available)z
  %-*s  %s)rÉ   rF   rU   r¶   r.   ÚAttributeError)rb   ru   rt   Ú
max_lengthÚcmdrÊ   r.   r   r   r   Úprint_command_listÇ  s    


zDistribution.print_command_listc                 C   sž   dd l }|jj}i }|D ]}d||< qg }| j ¡ D ]}| |¡s4| |¡ q4d}|| D ]}t|ƒ|krZt|ƒ}qZ|  |d|¡ |ršt	ƒ  |  |d|¡ d S )Nr   r   zStandard commandszExtra commands)
Údistutils.commandrf   Ú__all__rF   rq   rU   r„   r¨   rÒ   rÉ   )rb   rz   Ústd_commandsÚis_stdrÑ   Úextra_commandsrÐ   r   r   r   rË   Ø  s.    


þþzDistribution.print_commandsc           	   	   C   s®   dd l }|jj}i }|D ]}d||< qg }| j ¡ D ]}| |¡s4| |¡ q4g }|| D ]N}| j |¡}|sx|  |¡}z
|j}W n t	y˜   d}Y n0 | ||f¡ qZ|S )Nr   r   rÎ   )
rÓ   rf   rÔ   rF   rq   rU   r„   r¶   r.   rÏ   )	rb   rz   rÕ   rÖ   rÑ   r×   ÚrvrÊ   r.   r   r   r   Úget_command_listù  s(    	




zDistribution.get_command_listc                 C   sN   | j }t|tƒsJ|d u rd}dd„ | d¡D ƒ}d|vrD| dd¡ || _ |S )Nr;   c                 S   s   g | ]}|d kr|  ¡ ‘qS )r;   rÁ   )r6   Úpkgr   r   r   r8   !  r9   z5Distribution.get_command_packages.<locals>.<listcomp>rÃ   zdistutils.commandr   )rG   r   r   rs   Úinsert)rb   Zpkgsr   r   r   Úget_command_packages  s    
z!Distribution.get_command_packagesc              	   C   s´   | j  |¡}|r|S |  ¡ D ]†}d||f }|}zt|ƒ tj| }W n ty\   Y qY n0 zt||ƒ}W n$ ty�   t	d|||f ƒ‚Y n0 || j |< |  S t	d| ƒ‚d S )Nz%s.%sz3invalid command '%s' (no class '%s' in module '%s')zinvalid command '%s')
rF   rU   rÜ   Ú
__import__rZ   r€   ÚImportErrorrE   rÏ   r·   )rb   rf   rÊ   ZpkgnameÚmodule_nameZ
klass_nameÚmoduler   r   r   r¶   '  s,    
ÿÿ

zDistribution.get_command_classc                 C   sl   | j  |¡}|sh|rhtr&|  d| ¡ |  |¡}|| ƒ }| j |< d| j|< | j |¡}|rh|  ||¡ |S )Nz<Distribution.get_command_obj(): creating '%s' command objectr   )rS   rU   r   rr   r¶   rT   rJ   Ú_set_command_options)rb   rf   ZcreateÚcmd_objrÊ   r<   r   r   r   Úget_command_objM  s    ÿ

zDistribution.get_command_objc                 C   sZ  |  ¡ }|d u r|  |¡}tr,|  d| ¡ | ¡ D �]\}\}}trZ|  d|||f ¡ zdd„ |jD ƒ}W n ty„   g }Y n0 z
|j}W n ty¦   i }Y n0 z|t|t	ƒ}	||v rØ|	rØt
||| t|ƒ ƒ nJ||v rö|	röt
||t|ƒƒ n,t||ƒ�rt
|||ƒ ntd|||f ƒ‚W q4 t�yR }
 zt|
ƒ‚W Y d }
~
q4d }
~
0 0 q4d S )Nz#  setting options for '%s' command:z    %s = %s (from %s)c                 S   s   g | ]}t |ƒ‘qS r   r5   )r6   Úor   r   r   r8   |  s   ÿz5Distribution._set_command_options.<locals>.<listcomp>z1error in %s: command '%s' has no such option '%s')Úget_command_namerW   r   rr   rV   Zboolean_optionsrÏ   r”   r   r   rA   r   r]   r–   r•   )rb   rS   Zoption_dictÚcommand_namerÌ   Úsourcer   Z	bool_optsZneg_optZ	is_stringr   r   r   r   rá   h  sF    	

ÿÿ




ÿÿz!Distribution._set_command_optionsr   c                 C   s|   ddl m} t||ƒs&|}|  |¡}n| ¡ }|js8|S | ¡  d|_d| j|< |  |¡ |rx| 	¡ D ]}|  
||¡ qf|S )Nr   r®   )r²   r¯   r   rã   rå   Z	finalizedZinitialize_optionsrT   rá   Zget_sub_commandsÚreinitialize_command)rb   rf   Zreinit_subcommandsr¯   ræ   Úsubr   r   r   rè   ”  s    


z!Distribution.reinitialize_commandc                 C   s   t   ||¡ d S rm   r	   )rb   r   Úlevelr   r   r   rr   ½  s    zDistribution.announcec                 C   s   | j D ]}|  |¡ qd S rm   )ru   Úrun_command)rb   rÑ   r   r   r   Úrun_commandsÀ  s    
zDistribution.run_commandsc                 C   sD   | j  |¡rd S t d|¡ |  |¡}| ¡  | ¡  d| j |< d S )Nz
running %sr   )rT   rU   r
   Úinforã   Zensure_finalizedÚrun)rb   rf   râ   r   r   r   rë   Ê  s    	
zDistribution.run_commandc                 C   s   t | jp| jpg ƒdkS ©Nr   )r¨   rK   rL   r­   r   r   r   Úhas_pure_modulesÞ  s    zDistribution.has_pure_modulesc                 C   s   | j ot| j ƒdkS rï   )rO   r¨   r­   r   r   r   Úhas_ext_modulesá  s    zDistribution.has_ext_modulesc                 C   s   | j ot| j ƒdkS rï   )rM   r¨   r­   r   r   r   Úhas_c_librariesä  s    zDistribution.has_c_librariesc                 C   s   |   ¡ p|  ¡ S rm   )rð   rñ   r­   r   r   r   Úhas_modulesç  s    zDistribution.has_modulesc                 C   s   | j ot| j ƒdkS rï   )rN   r¨   r­   r   r   r   Úhas_headersê  s    zDistribution.has_headersc                 C   s   | j ot| j ƒdkS rï   )rP   r¨   r­   r   r   r   Úhas_scriptsí  s    zDistribution.has_scriptsc                 C   s   | j ot| j ƒdkS rï   )rQ   r¨   r­   r   r   r   Úhas_data_filesð  s    zDistribution.has_data_filesc                 C   s   |   ¡ o|  ¡  o|  ¡  S rm   )rð   rñ   rò   r­   r   r   r   Úis_pureó  s
    ÿþzDistribution.is_pure)N)NNr;   )N)r   )N)r   )(r   Ú
__module__Ú__qualname__r¬   rÈ   r¡   r@   r”   rl   rW   ry   r‡   r�   r«   r¢   r¦   ra   r§   r¥   rÒ   rË   rÙ   rÜ   r¶   rã   rá   rè   r
   ÚINFOrr   rì   rë   rð   rñ   rò   ró   rô   rõ   rö   r÷   r   r   r   r   r   ,   sL   ,
 
0
:C[ÿ
2(!"&

,
)
r   c                   @   s  e Zd ZdZdAdd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ ZeZd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Z d;d<„ Z!d=d>„ Z"d?d@„ Z#dS )BrB   )r#   r$   r'   Úauthor_emailr)   Úmaintainer_emailr+   r,   r.   Úlong_descriptionr1   r/   r&   r*   Zcontact_emailr0   Údownload_urlr2   r3   r4   Nc                 C   s‚   |d ur|   t|ƒ¡ nfd | _d | _d | _d | _d | _d | _d | _d | _	d | _
d | _d | _d | _d | _d | _d | _d | _d | _d S rm   )Úread_pkg_fileÚopenr#   r$   r'   rû   r)   rü   r+   r,   r.   rý   r1   r/   r0   rþ   r2   r3   r4   )rb   r~   r   r   r   rl     s&    zDistributionMetadata.__init__c                    s  t |ƒ‰ ‡ fdd„}‡ fdd„}ˆ d }|dƒ| _|dƒ| _|dƒ| _|d	ƒ| _d | _|d
ƒ| _d | _|dƒ| _|dƒ| _	dˆ v rŽ|dƒ| _
nd | _
|dƒ| _|dƒ| _dˆ v rÀ|dƒ d¡| _|dƒ| _|dƒ| _|dkrü|dƒ| _|dƒ| _|dƒ| _nd | _d | _d | _d S )Nc                    s   ˆ |  }|dkrd S |S ©NZUNKNOWNr   )r#   r   ©r   r   r   Ú_read_field(  s    z7DistributionMetadata.read_pkg_file.<locals>._read_fieldc                    s   ˆ   | d ¡}|g krd S |S rm   )Zget_all)r#   Úvaluesr  r   r   Ú
_read_list.  s    z6DistributionMetadata.read_pkg_file.<locals>._read_listzmetadata-versionr#   r$   Zsummaryr'   r(   z	home-pager,   zdownload-urlr.   r1   rÃ   ÚplatformZ
classifierú1.1r3   r2   r4   )r   r#   r$   r.   r'   r)   rû   rü   r+   r,   rþ   rý   rs   r1   r/   r0   r3   r2   r4   )rb   Úfiler  r  Zmetadata_versionr   r  r   rÿ   $  s:    












z"DistributionMetadata.read_pkg_filec                 C   sF   t tj |d¡ddd��}|  |¡ W d   ƒ n1 s80    Y  d S )NzPKG-INFOÚwzUTF-8)Úencoding)r   r}   r~   r‚   Úwrite_pkg_file)rb   Úbase_dirZpkg_infor   r   r   Úwrite_pkg_infoX  s
    ÿz#DistributionMetadata.write_pkg_infoc                 C   sb  d}| j s"| js"| js"| js"| jr&d}| d| ¡ | d|  ¡  ¡ | d|  ¡  ¡ | d|  ¡  ¡ | d|  	¡  ¡ | d|  
¡  ¡ | d	|  ¡  ¡ | d
|  ¡  ¡ | jrÈ| d| j ¡ t|  ¡ ƒ}| d| ¡ d |  ¡ ¡}|�r| d| ¡ |  |d|  ¡ ¡ |  |d|  ¡ ¡ |  |d|  ¡ ¡ |  |d|  ¡ ¡ |  |d|  ¡ ¡ d S )Nz1.0r  zMetadata-Version: %s
z	Name: %s
zVersion: %s
zSummary: %s
zHome-page: %s
zAuthor: %s
zAuthor-email: %s
zLicense: %s
zDownload-URL: %s
zDescription: %s
rÃ   zKeywords: %s
ZPlatformZ
ClassifierZRequiresZProvidesZ	Obsoletes)r2   r3   r4   r0   rþ   r\   Úget_nameÚget_versionÚget_descriptionÚget_urlÚget_contactÚget_contact_emailÚget_licenser   Úget_long_descriptionr‚   Úget_keywordsÚ_write_listÚget_platformsÚget_classifiersÚget_requiresÚget_providesÚget_obsoletes)rb   r  r$   Z	long_descr1   r   r   r   r  _  s6    ÿÿz#DistributionMetadata.write_pkg_filec                 C   s    |D ]}|  d||f ¡ qd S )Nz%s: %s
)r\   )rb   r  r#   r  r   r   r   r   r  �  s    z DistributionMetadata._write_listc                 C   s
   | j pdS r  )r#   r­   r   r   r   r  ‡  s    zDistributionMetadata.get_namec                 C   s
   | j pdS )Nz0.0.0)r$   r­   r   r   r   r  Š  s    z DistributionMetadata.get_versionc                 C   s   d|   ¡ |  ¡ f S )Nz%s-%s)r  r  r­   r   r   r   Úget_fullname�  s    z!DistributionMetadata.get_fullnamec                 C   s
   | j pdS r  )r'   r­   r   r   r   Ú
get_author�  s    zDistributionMetadata.get_authorc                 C   s
   | j pdS r  )rû   r­   r   r   r   Úget_author_email“  s    z%DistributionMetadata.get_author_emailc                 C   s
   | j pdS r  )r)   r­   r   r   r   Úget_maintainer–  s    z#DistributionMetadata.get_maintainerc                 C   s
   | j pdS r  )rü   r­   r   r   r   Úget_maintainer_email™  s    z)DistributionMetadata.get_maintainer_emailc                 C   s   | j p| jpdS r  )r)   r'   r­   r   r   r   r  œ  s    z DistributionMetadata.get_contactc                 C   s   | j p| jpdS r  )rü   rû   r­   r   r   r   r  Ÿ  s    z&DistributionMetadata.get_contact_emailc                 C   s
   | j pdS r  )r+   r­   r   r   r   r  ¢  s    zDistributionMetadata.get_urlc                 C   s
   | j pdS r  )r,   r­   r   r   r   r  ¥  s    z DistributionMetadata.get_licensec                 C   s
   | j pdS r  )r.   r­   r   r   r   r  ©  s    z$DistributionMetadata.get_descriptionc                 C   s
   | j pdS r  )rý   r­   r   r   r   r  ¬  s    z)DistributionMetadata.get_long_descriptionc                 C   s
   | j pg S rm   )r1   r­   r   r   r   r  ¯  s    z!DistributionMetadata.get_keywordsc                 C   s   t |dƒ| _d S )Nr1   )r   r1   ©rb   r   r   r   r   Úset_keywords²  s    z!DistributionMetadata.set_keywordsc                 C   s   | j p
dgS r  )r/   r­   r   r   r   r  µ  s    z"DistributionMetadata.get_platformsc                 C   s   t |dƒ| _d S )Nr/   )r   r/   r"  r   r   r   Úset_platforms¸  s    z"DistributionMetadata.set_platformsc                 C   s
   | j pg S rm   )r0   r­   r   r   r   r  »  s    z$DistributionMetadata.get_classifiersc                 C   s   t |dƒ| _d S )Nr0   )r   r0   r"  r   r   r   Úset_classifiers¾  s    z$DistributionMetadata.set_classifiersc                 C   s
   | j pdS r  )rþ   r­   r   r   r   Úget_download_urlÁ  s    z%DistributionMetadata.get_download_urlc                 C   s
   | j pg S rm   )r3   r­   r   r   r   r  Å  s    z!DistributionMetadata.get_requiresc                 C   s,   dd l }|D ]}|j |¡ qt|ƒ| _d S rï   )Údistutils.versionpredicateÚversionpredicateÚVersionPredicater   r3   ©rb   r   rz   r   r   r   r   Úset_requiresÈ  s    z!DistributionMetadata.set_requiresc                 C   s
   | j pg S rm   )r2   r­   r   r   r   r  Î  s    z!DistributionMetadata.get_providesc                 C   s6   dd„ |D ƒ}|D ]}dd l }|j |¡ q|| _d S )Nc                 S   s   g | ]}|  ¡ ‘qS r   rÁ   )r6   r   r   r   r   r8   Ò  r9   z5DistributionMetadata.set_provides.<locals>.<listcomp>r   )r'  r(  Zsplit_provisionr2   )rb   r   r   rz   r   r   r   Úset_providesÑ  s
    z!DistributionMetadata.set_providesc                 C   s
   | j pg S rm   )r4   r­   r   r   r   r  Ø  s    z"DistributionMetadata.get_obsoletesc                 C   s,   dd l }|D ]}|j |¡ qt|ƒ| _d S rï   )r'  r(  r)  r   r4   r*  r   r   r   Úset_obsoletesÛ  s    z"DistributionMetadata.set_obsoletes)N)$r   rø   rù   rD   rl   rÿ   r  r  r  r  r  r  r  r  r   r!  r  r  r  r  Zget_licencer  r  r  r#  r  r$  r  r%  r&  r  r+  r  r,  r  r-  r   r   r   r   rB   ÿ  sB   	
4"rB   c                 C   s$   g }| D ]}|  |dd… ¡ q|S )Nr   é   )r„   )r<   Znew_optionsZ
help_tupler   r   r   r»   á  s    r»   )rZ   r}   ÚreZemailr   rX   rÞ   Zdistutils.errorsZdistutils.fancy_getoptr   r   Zdistutils.utilr   r   r   rz   r
   Zdistutils.debugr   Úcompiler³   r   r   rB   r»   r   r   r   r   Ú<module>   s2   

       Z c