509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \X  ã               @   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j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)ú
build-dir=Údúdirectory to "build" (copy) toÚforceÚfú1forcibly build everything (ignore file timestampsúexecutable=Úeú*specify final destination interpreter pathc             C   s"   d | _ d | _d | _d | _d | _d S )N)Ú	build_dirÚscriptsr   Ú
executableÚoutfiles)Úself© r   ú7/usr/lib64/python3.6/distutils/command/build_scripts.pyÚinitialize_options   s
    z build_scripts.initialize_optionsc             C   s   | j ddddƒ | jj| _d S )	NZbuildr	   r   r   r   )r	   r   )r   r   )r   r   )Zset_undefined_optionsZdistributionr   )r   r   r   r   Úfinalize_options%   s
    zbuild_scripts.finalize_optionsc             C   s   | j S )N)r   )r   r   r   r   Úget_source_files,   s    zbuild_scripts.get_source_filesc             C   s   | j s
d S | jƒ  d S )N)r   Úcopy_scripts)r   r   r   r   Úrun/   s    zbuild_scripts.runc          "   C   sÂ  | j | jƒ g }g }�x,| jD �] }d}t|ƒ}tjj| jtjj|ƒƒ}|j|ƒ | j	 rtt
||ƒ rttjd|ƒ qyt|dƒ}W n  tk
r¢   | jsš‚ d}Y nXX tj|jƒ\}}|jdƒ |jƒ }	|	sÚ| jd| ƒ qtj|	ƒ}
|
rúd}|
jdƒpød	}|�rtjd
|| jƒ |j|ƒ | j�stj�s2| j}n(tjjtjdƒdtjdƒtjdƒf ƒ}tj|ƒ}d| | d }y|jdƒ W n$ tk
�r¦   t dj!|ƒƒ‚Y nX y|j|ƒ W n& tk
�rÜ   t dj!||ƒƒ‚Y nX t|dƒ�}|j"|ƒ |j#|j$ƒ ƒ W dQ R X |�r@|j%ƒ  q|�r*|j%ƒ  |j|ƒ | j&||ƒ qW tj'dk�rºxh|D ]`}| j�rptjd|ƒ nDtj(|ƒt) d@ }|dB d@ }||k�rVtjd|||ƒ tj*||ƒ �qVW ||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)+Z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   Zpython_buildr   Úget_config_varÚfsencodeÚdecodeÚUnicodeDecodeErrorÚ
ValueErrorÚformatÚwriteÚ
writelinesÚ	readlinesÚcloseZ	copy_fileÚnameÚstatr   Úchmod)r   r   Úupdated_filesZscriptZadjustZoutfiler   ÚencodingÚlinesZ
first_liner7   Zpost_interpr   ZshebangZoutfÚfileZoldmodeZnewmoder   r   r   r   5   s�    












zbuild_scripts.copy_scriptsN)r
   r   r   )r   r   r   )r   r   r   )Ú__name__Ú
__module__Ú__qualname__ZdescriptionZuser_optionsZ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| ƒ\}}| js| j|ƒ ||fS )N)r	   r   r0   Zrun_2to3)r   r   rG   r   r   r   r   œ   s    
zbuild_scripts_2to3.copy_scriptsN)rK   rL   rM   r   r   r   r   r   rN   š   s   rN   )Ú__doc__r(   ÚrerE   r   Z	distutilsr   Zdistutils.corer   Zdistutils.dep_utilr   Zdistutils.utilr   r   r   r1   Úcompiler6   r	   rN   r   r   r   r   Ú<module>   s   
 
