a (ReK@sdZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddlm Z ddlZed ZGd d d eZdS) zRdistutils.command.build_scripts Implements the Distutils 'build_scripts' command.N)ST_MODE) sysconfig)Command)newer) convert_path)logs^#!.*python[0-9.]*([ ].*)?$c@sFeZdZdZgdZdgZddZddZdd Zd d Z d d Z dS) build_scriptsz("build" scripts (copy and fixup #! line)))z build-dir=dzdirectory to "build" (copy) to)forcefz1forcibly build everything (ignore file timestamps)z executable=ez*specify final destination interpreter pathr cCs"d|_d|_d|_d|_d|_dSN) build_dirscriptsr executableoutfilesselfr/builddir/build/BUILDROOT/alt-python39-setuptools-58.3.0-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/setuptools/_distutils/command/build_scripts.pyinitialize_optionss z build_scripts.initialize_optionscCs|dddd|jj|_dS)Nbuild)rr)r r )rr)set_undefined_options distributionrrrrrfinalize_options%s zbuild_scripts.finalize_optionscCs|jSr )rrrrrget_source_files,szbuild_scripts.get_source_filescCs|js dS|dSr )r copy_scriptsrrrrrun/szbuild_scripts.runc Cs||jg}g}|jD],}d}t|}tj|jtj|}|||j slt ||slt d|qzt |d}Wnty|jsd}YnX0t|j\}}|d|} | s|d|qt| } | rd}| dpd } |r$t d ||j|||jstjs(|j} n(tjtd d td tdf} t| } d| | d} z| dWn"tyt d!| Yn0z| |Wn$tyt d!| |Yn0t |d(}|"| |#|$Wdn1s 0Y|rH|%q|r2|%|||&||qtj'dkr|D]`}|jrtt d|nDt(|t)d@}|dBd@}||krZt d|||t*||qZ||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)rbNrz%s is an empty file (skipping)Tzcopying 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 %siimz!changing mode of %s from %o to %o)+mkpathrrrospathjoinbasenameappendr rrdebugopenOSErrordry_runtokenizedetect_encodingreadlineseekwarn first_line_rematchgroupinfor python_buildrget_config_varfsencodedecodeUnicodeDecodeError ValueErrorformatwrite writelines readlinesclose copy_filenamestatrchmod)rrZ updated_filesscriptadjustoutfiler encodinglines first_liner7 post_interprshebangoutffileZoldmodeZnewmoderrrr5s               .     zbuild_scripts.copy_scriptsN) __name__ __module__ __qualname__ description user_optionsboolean_optionsrrrrrrrrrrsr)__doc__r(rerGr distutilsrdistutils.corerdistutils.dep_utilrdistutils.utilrrr1compiler6rrrrrs