
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    š’aX  ã                   @   s˜   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZmZ ddlmZ ddlZe d	¡ZG d
d„ deƒZG dd„ deeƒZdS )zRdistutils.command.build_scripts

Implements the Distutils 'build_scripts' command.é    N)ÚST_MODE)Ú	sysconfig)ÚCommand)Únewer)Úconvert_pathÚ	Mixin2to3)Úlogs   ^#!.*python[0-9.]*([ 	].*)?$c                   @   sH   e Zd ZdZdddgZdgZdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )Úbuild_scriptsz("build" scripts (copy and fixup #! line))z
build-dir=Údzdirectory to "build" (copy) to)ÚforceÚfz1forcibly build everything (ignore file timestamps)zexecutable=Úez*specify final destination interpreter pathr   c                 C   s"   d | _ d | _d | _d | _d | _d S ©N)Ú	build_dirÚscriptsr   Ú
executableÚoutfiles©Úself© r   úS/tmp/pip-install-7tp5dx2w/setuptools/setuptools/_distutils/command/build_scripts.pyÚinitialize_options   s
    z build_scripts.initialize_optionsc                 C   s   |   dddd¡ | jj| _d S )NÚbuild)r	   r   )r   r   )r   r   )Úset_undefined_optionsÚdistributionr   r   r   r   r   Úfinalize_options%   s    ýzbuild_scripts.finalize_optionsc                 C   s   | j S r   )r   r   r   r   r   Úget_source_files,   s    zbuild_scripts.get_source_filesc                 C   s   | j s
d S |  ¡  d S r   )r   Úcopy_scriptsr   r   r   r   Úrun/   s    zbuild_scripts.runc              
   C   s´  |   | j¡ g }g }| jD �]}d}t|ƒ}tj | jtj |¡¡}| |¡ | j	slt
||ƒslt d|¡ qzt|dƒ}W n  tk
rš   | js’‚ d}Y nXX t |j¡\}}| d¡ | ¡ }	|	sÒ|  d| ¡ qt |	¡}
|
ròd}|
 d¡pðd	}|�rt d
|| j¡ | |¡ | j�stj�s*| j}n(tj t d¡dt d¡t d¡f ¡}t |¡}d| | d }z| d¡ W n$ tk
�rž   t d !|¡ƒ‚Y nX z| |¡ W n& tk
�rÔ   t d !||¡ƒ‚Y nX t|dƒ�}| "|¡ | #| $¡ ¡ W 5 Q R X |�r8| %¡  q|�r"| %¡  | |¡ |  &||¡ qtj'dk�r¬|D ]`}| j�rdt d|¡ nDt (|¡t) d@ }|dB d@ }||k�rJt d|||¡ t *||¡ �qJ||fS )a"  Copy each script listed in 'self.scripts'; if it's marked as a
        Python script in the Unix way (first line matches 'first_line_re',
        ie. starts with "\#!" and contains "python"), then adjust the first
        line to refer to the current Python interpreter as we copy.
        Fznot copying %s (up-to-date)ÚrbNr   z%s is an empty file (skipping)Té   ó    zcopying and adjusting %s -> %sÚBINDIRz
python%s%sÚVERSIONÚEXEs   #!ó   
zutf-8z.The shebang ({!r}) is not decodable from utf-8zAThe shebang ({!r}) is not decodable from the script encoding ({})ÚwbÚposixzchanging mode of %siÿ  im  z!changing mode of %s from %o to %o)+Úmkpathr   r   r   ÚosÚpathÚjoinÚbasenameÚappendr   r   r   ÚdebugÚopenÚOSErrorÚdry_runÚtokenizeÚdetect_encodingÚreadlineÚseekÚwarnÚfirst_line_reÚmatchÚgroupÚinfor   Úpython_buildr   Úget_config_varÚfsencodeÚdecodeÚUnicodeDecodeErrorÚ
ValueErrorÚformatÚwriteÚ
writelinesÚ	readlinesÚcloseÚ	copy_fileÚnameÚstatr   Úchmod)r   r   Úupdated_filesÚscriptÚadjustÚoutfiler   ÚencodingÚlinesÚ
first_liner8   Úpost_interpr   ÚshebangÚoutfÚfileZoldmodeZnewmoder   r   r   r   5   s¦    



ÿ

ÿþ
ÿÿ
 þÿ




  ÿzbuild_scripts.copy_scriptsN)Ú__name__Ú
__module__Ú__qualname__ÚdescriptionÚuser_optionsÚboolean_optionsr   r   r   r   r   r   r   r   r   r	      s   ýr	   c                   @   s   e Zd Zdd„ ZdS )Úbuild_scripts_2to3c                 C   s&   t  | ¡\}}| js|  |¡ ||fS r   )r	   r   r1   Úrun_2to3)r   r   rJ   r   r   r   r   œ   s    
zbuild_scripts_2to3.copy_scriptsN)rU   rV   rW   r   r   r   r   r   r[   š   s   r[   )Ú__doc__r)   ÚrerH   r   Ú	distutilsr   Údistutils.corer   Údistutils.dep_utilr   Údistutils.utilr   r   r   r2   Úcompiler7   r	   r[   r   r   r   r   Ú<module>   s   
 
