
|«‘_‡	  ã               @   ss   d  d l  m Z d  d l j j Z d  d l Z d  d l Z d  d l m	 Z	 m
 Z
 m Z Gd 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 j |  ƒ d |  _ d  S)NF)Úorigr   Úinitialize_optionsÚno_ep)Úself© r   úH/tmp/pip-build-3_sjtvrs/setuptools/setuptools/command/install_scripts.pyr      s    z"install_scripts.initialize_optionsc             C   s`  d d  l  j j } |  j d ƒ |  j j r> t j j |  ƒ n	 g  |  _	 |  j
 rT d  S|  j d ƒ } t | j t | j | j ƒ | j | j ƒ } |  j d ƒ } t | d d  ƒ } |  j d ƒ } t | d d ƒ } | j } | rð d } | j } | t j k r| g } | j ƒ  } | j j ƒ  j | ƒ }	 x- | j | |	 j ƒ  ƒ D] }
 |  j |
 Œ  qEWd  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_paramZ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      s2    					zinstall_scripts.runÚtc       
      G   s¯   d d l  m } m } t j d | |  j ƒ t j j |  j | ƒ } |  j	 j
 | ƒ | ƒ  } |  j s« t | ƒ t | d | ƒ }	 |	 j | ƒ |	 j ƒ  | | 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   ÚinfoÚ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)Ú__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
   