U
    ui=
                     @  sh   d dl mZ d dlZd dlZddlmZ ddlmZ d dlm	  m
Z d dlmZ G dd dej
Z
dS )	    )annotationsN   )ensure_directory)Distribution)logc                   @  sH   e Zd ZU dZded< dd Zdddd	Zd
d ZdddddZdS )install_scriptsz;Do normal script install, plus any egg_info wrapper scriptsr   distributionc                 C  s   t j|  d| _d S )NF)origr   initialize_optionsno_epself r   F/tmp/pip-unpacked-wheel-9osl9suo/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)	run_commandr   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|
  qd S )Nr   )r   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_param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tstr)modec              	   G  s   ddl m}m} td|| j tj| j|}| j	
| d|krHdnd}| }	| jst| 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/   r0   r   infoZinstall_dirospathjoinr   appenddry_runr   openwrite)r   script_namecontentsr.   Zignoredr/   r0   targetr3   maskfr   r   r   r&   ;   s    zinstall_scripts.write_scriptN)r,   )	__name__
__module____qualname____doc____annotations__r
   r   r   r&   r   r   r   r   r      s   
r   )
__future__r   r5   r"   _pathr   r(   r   Z!distutils.command.install_scriptscommandr   r	   	distutilsr   r   r   r   r   <module>   s   