U
ReK @ s d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddlm
Z
ddlZed ZG d
d deZdS )zRdistutils.command.build_scripts
Implements the Distutils 'build_scripts' command. N)ST_MODE) sysconfig)Command)newer)convert_path)logs ^#!.*python[0-9.]*([ ].*)?$c @ sH e Zd ZdZdddgZdgZdd Zdd Zd
d Zdd
Z dd Z
dS )
build_scriptsz("build" scripts (copy and fixup #! line))z
build-dir=dzdirectory to "build" (copy) to)forcefz1forcibly build everything (ignore file timestamps)zexecutable=ez*specify final destination interpreter pathr
c C s" d | _ d | _d | _d | _d | _d S N) build_dirscriptsr
executableoutfilesself r /builddir/build/BUILDROOT/alt-python38-setuptools-58.3.0-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/setuptools/_distutils/command/build_scripts.pyinitialize_options s
z build_scripts.initialize_optionsc C s | dddd | jj| _d S )Nbuild)r r )r
r
)r r )set_undefined_optionsdistributionr r r r r finalize_options% s zbuild_scripts.finalize_optionsc C s | j S r
)r r r r r get_source_files, s zbuild_scripts.get_source_filesc C s | j s
d S | d S r
)r copy_scriptsr r r r run/ s zbuild_scripts.runc
C s | | j g }g }| jD ]}d}t|}tj| jtj|}|| | j slt
||sltd| qzt
|d}W n tk
r | js d}Y nXX t|j\}}|d | } | s| d| qt| }
|
rd}|
dpd }|rtd
|| j || | jstjs*| j}n(tjtddtd
tdf }t|}d| | d }
z|
d W n$ tk
r t d!|
Y nX z|
| W n& tk
r t d!|
|Y nX t
|d}|"|
|#|$ W 5 Q R X |r8|% q|r"|% || | &|| qtj'dkr|D ]`}| jrdtd| nDt(|t) d@ }|dB d@ }||krJtd||| t*|| qJ||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)+mkpathr r r ospathjoinbasenameappendr
r r debugopenOSErrordry_runtokenizedetect_encodingreadlineseekwarn
first_line_rematchgroupinfor python_buildr get_config_varfsencodedecodeUnicodeDecodeError
ValueErrorformatwrite
writelines readlinesclose copy_filenamestatr chmod)r r Z
updated_filesscriptadjustoutfiler encodinglines
first_liner7 post_interpr shebangoutffileZoldmodeZnewmoder r r r 5 s
zbuild_scripts.copy_scriptsN)__name__
__module____qualname__descriptionuser_optionsboolean_optionsr r r r r r r r r r s r )__doc__r( rerG r distutilsr distutils.corer distutils.dep_utilr distutils.utilr r r1 compiler6 r r r r r