3
\X @ s d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZ ddlZejd ZG d
d deZG dd
d
ee
ZdS )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 Zd ZdZdddgZdgZdd Zd
d Zdd Zdd Z dd Z
dS )
build_scriptsz("build" scripts (copy and fixup #! line)
build-dir=ddirectory to "build" (copy) toforcef1forcibly build everything (ignore file timestampsexecutable=e*specify final destination interpreter pathc C s" d | _ d | _d | _d | _d | _d S )N) build_dirscriptsr
executableoutfiles)self r 7/usr/lib64/python3.6/distutils/command/build_scripts.pyinitialize_options s
z build_scripts.initialize_optionsc C s | j dddd | jj| _d S ) NZbuildr r r
r )r r )r
r
)r r )Zset_undefined_optionsZdistributionr )r r r r finalize_options% s
zbuild_scripts.finalize_optionsc C s | j S )N)r )r r r r get_source_files, s zbuild_scripts.get_source_filesc C s | j s
d S | j d S )N)r copy_scripts)r r r r run/ s zbuild_scripts.runc " C s | j | j g }g }x,| jD ] }d}t|}tjj| jtjj|}|j| | j rtt
|| rttjd| qyt
|d}W n tk
r | js d}Y nXX tj|j\}}|jd |j } | s| jd| qtj| }
|
rd}|
jdpd }|rtjd
|| j |j| | jstjs2| j}n(tjjtjddtjd
tjdf }tj|}d| | d }
y|
jd W n$ tk
r t dj!|
Y nX y|
j| W n& tk
r t dj!|
|Y nX t
|d}|j"|
|j#|j$ W dQ R X |r@|j% q|r*|j% |j| | j&|| qW tj'dkrxh|D ]`}| jrptjd| nDtj(|t) d@ }|dB d@ }||krVtjd||| tj*|| qVW ||fS )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.
Fznot copying %s (up-to-date)rbNr z%s is an empty file (skipping)T zcopying and adjusting %s -> %sBINDIRz
python%s%sVERSIONEXEs #!
zutf-8z.The shebang ({!r}) is not decodable from utf-8zAThe shebang ({!r}) is not decodable from the script encoding ({})wbposixzchanging mode of %si im z!changing mode of %s from %o to %o)+Zmkpathr r r ospathjoinbasenameappendr
r r debugopenOSErrordry_runtokenizedetect_encodingreadlineseekwarn
first_line_rematchgroupinfor Zpython_buildr get_config_varfsencodedecodeUnicodeDecodeError
ValueErrorformatwrite
writelines readlinescloseZ copy_filenamestatr chmod)r r
updated_filesZscriptZadjustZoutfiler encodinglinesZ
first_liner7 Zpost_interpr ZshebangZoutffileZoldmodeZnewmoder r r r 5 s
zbuild_scripts.copy_scriptsN)r
r r )r
r r )r r r )__name__
__module____qualname__ZdescriptionZuser_optionsZboolean_optionsr r r r r r r r r r s r c @ s e Zd Zdd ZdS )build_scripts_2to3c C s&