U
    ±§fª	  ã                   @  s\   d dl mZ d dlmZ d dlm  mZ d dlZd dl	Z	ddl
mZ G dd„ dejƒZdS )é    )Úannotations)ÚlogNé   )Úensure_directoryc                   @  s8   e Zd ZdZdd„ Zddœdd„Zdd	„ Zddd„ZdS )Úinstall_scriptsz;Do normal script install, plus any egg_info wrapper scriptsc                 C  s   t j | ¡ d| _d S )NF)Úorigr   Úinitialize_optionsÚno_ep©Úself© r   úAlib/python3.8/site-packages/setuptools/command/install_scripts.pyr      s    z"install_scripts.initialize_optionsÚNone)Úreturnc                 C  s<   |   d¡ | jjr tj | ¡ ng | _| jr0d S |  ¡  d S )NÚegg_info)	Zrun_commandZdistributionZscriptsr   r   ÚrunÚoutfilesr	   Ú_install_ep_scriptsr
   r   r   r   r      s    
zinstall_scripts.runc                 C  s¬   ddl m}m} ddlm} |  d¡}||j||j|jƒ|j|j	ƒ}|  d¡}t
|dd ƒ}|j}|tjkrp|g}| ¡ }|j ¡  |¡}	| ||	 ¡ ¡D ]}
| j|
Ž  q˜d S )Nr   )ÚDistributionÚPathMetadataé   )Úeasy_installr   Zbuild_scriptsÚ
executable)Zpkg_resourcesr   r   Ú r   Zget_finalized_commandZegg_baser   Zegg_nameZegg_versionÚgetattrZScriptWriterÚsysr   ZbestZcommand_spec_classZ
from_paramZget_argsZ	as_headerÚwrite_script)r   r   r   ZeiZei_cmdZdistZbs_cmdZ
exec_paramÚwriterÚcmdÚargsr   r   r   r      s$    
ü

z#install_scripts._install_ep_scriptsÚtc              	   G  sš   ddl m}m} t d|| j¡ tj | j|¡}| j	 
|¡ d|krHdnd}|ƒ }	| js–t|ƒ t|d| |d}
|
 |¡ W 5 Q R X ||d	|	 ƒ dS )
z1Write an executable file to the scripts directoryr   )ÚchmodÚcurrent_umaskzInstalling %s script to %sÚbNzutf-8Úw)Úencodingiÿ  )Zsetuptools.command.easy_installr!   r"   r   ÚinfoZinstall_dirÚosÚpathÚjoinr   ÚappendZdry_runr   ÚopenÚwrite)r   Úscript_nameÚcontentsÚmodeZignoredr!   r"   Útargetr%   ÚmaskÚfr   r   r   r   6   s    zinstall_scripts.write_scriptN)r    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s
   r   )Z
__future__r   Ú	distutilsr   Z!distutils.command.install_scriptsZcommandr   r   r'   r   Ú_pathr   r   r   r   r   Ú<module>   s   