U
    ô_Üd7	  ã                   @   sP   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 )é    )ÚlogNé   )Úensure_directoryc                   @   s2   e Zd ZdZdd„ Z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   úJ/tmp/pip-install-m_ue_qtn/setuptools/setuptools/command/install_scripts.pyr      s    z"install_scripts.initialize_optionsc                 C   s<   |   d¡ | jjr tj | ¡ ng | _| jr0d S |  ¡  d S )NÚegg_info)	Úrun_commandÚdistributionÚ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   Úbuild_scriptsÚ
executable)Úpkg_resourcesr   r   Ú r   Úget_finalized_commandZegg_baser   Úegg_nameZegg_versionÚgetattrZScriptWriterÚsysr   ÚbestZcommand_spec_classÚ
from_paramZget_argsZ	as_headerÚwrite_script)r
   r   r   ÚeiZei_cmdÚ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	 
|¡ |ƒ }| js~t|ƒ t|d| ƒ}	|	 |¡ |	 ¡  ||d| ƒ dS )z1Write an executable file to the scripts directoryr   )ÚchmodÚcurrent_umaskzInstalling %s script to %sÚwiÿ  N)Zsetuptools.command.easy_installr)   r*   r   ÚinfoZinstall_dirÚosÚpathÚjoinr   ÚappendÚdry_runr   ÚopenÚwriteÚclose)
r
   Úscript_nameÚcontentsÚmodeZignoredr)   r*   ÚtargetÚmaskÚfr   r   r   r"   4   s    
zinstall_scripts.write_scriptN)r(   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r"   r   r   r   r   r   	   s
   r   )
Ú	distutilsr   Z!distutils.command.install_scriptsÚcommandr   r   r-   r   Ú_pathr   r   r   r   r   Ú<module>   s
   