U
    ßUöe‡	  ã                   @   sX   d dl mZ d dlm  mZ d dlZd dlZd dlm	Z	m
Z
mZ G dd„ dejƒZdS )é    )ÚlogN)ÚDistributionÚPathMetadataÚensure_directoryc                   @   s*   e Zd Z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   úF/tmp/pip-unpacked-wheel-92716ek_/setuptools/command/install_scripts.pyr      s    z"install_scripts.initialize_optionsc                 C   sö   dd l m  m} |  d¡ | jjr2tj | ¡ ng | _	| j
rBd S |  d¡}t|jt|j|jƒ|j|jƒ}|  d¡}t|dd ƒ}|  d¡}t|ddƒ}|j}|rªd}|j}|tjkrº|g}| ¡ }|j ¡  |¡}	| ||	 ¡ ¡D ]}
| j|
Ž  qâd S )	Nr   Úegg_infoÚbuild_scriptsÚ
executableÚbdist_wininstZ_is_runningFz
python.exe)Úsetuptools.command.easy_installÚcommandÚeasy_installÚrun_commandÚdistributionÚscriptsr   r   ÚrunÚoutfilesr	   Úget_finalized_commandr   Zegg_baser   r   Úegg_nameZegg_versionÚgetattrZScriptWriterZWindowsScriptWriterÚsysr   ÚbestZcommand_spec_classÚ
from_paramÚget_argsZ	as_headerÚwrite_script)r
   ÚeiZei_cmdÚdistZbs_cmdZ
exec_paramZbw_cmdZ
is_wininstÚwriterÚcmdÚargsr   r   r   r      s8    

  þ


zinstall_scripts.runÚ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)r   r'   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    3   s    
zinstall_scripts.write_scriptN)r&   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r    r   r   r   r   r   	   s   #r   )Ú	distutilsr   Z!distutils.command.install_scriptsr   r   r   r+   r   Úpkg_resourcesr   r   r   r   r   r   r   Ú<module>   s
   