3 2aX@sddlZddlZddlmZddlmZddlmZddlm Z ddl m Z m Z ddlm Z ddlZejdZGd d d eZGd d d ee ZdS) N)ST_MODE) sysconfig)Command)newer) convert_path Mixin2to3)logs^#!.*python[0-9.]*([ ].*)?$c@sHeZdZdZdddgZdgZd d Zd dZddZddZ ddZ dS) build_scriptsz("build" scripts (copy and fixup #! line) build-dir=ddirectory to "build" (copy) toforcef1forcibly build everything (ignore file timestamps executable=e*specify final destination interpreter pathcCs"d|_d|_d|_d|_d|_dS)N) build_dirscriptsr executableoutfiles)selfr2/opt/alt/python36/lib64/python3.6/build_scripts.pyinitialize_optionss z build_scripts.initialize_optionscCs|jdddd|jj|_dS) NZbuildr rr r)r r)r r )rr)Zset_undefined_optionsZ distributionr)rrrrfinalize_options%s zbuild_scripts.finalize_optionscCs|jS)N)r)rrrrget_source_files,szbuild_scripts.get_source_filescCs|js dS|jdS)N)r copy_scripts)rrrrrun/szbuild_scripts.runc"Cs|j|jg}g}x,|jD] }d}t|}tjj|jtjj|}|j||j rtt || rtt j d|qyt |d}Wn tk r|jsd}YnXXtj|j\}}|jd|j} | s|jd|qtj| } | rd}| jdpd} |rt jd ||j|j||js tjs2|j} n(tjjtjd d tjd tjd f} tj| } d| | d} y| jdWn$tk rt dj!| YnXy| j|Wn&tk rt dj!| |YnXt |d}|j"| |j#|j$WdQRX|r@|j%q|r*|j%|j||j&||qWtj'dkrxh|D]`}|jrpt jd|nDtj(|t)d@}|dBd@}||krVt jd|||tj*||qVW||fS)NFznot copying %s (up-to-date)rbrz%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)+Zmkpathrrrospathjoinbasenameappendr rrdebugopenOSErrordry_runtokenizedetect_encodingreadlineseekwarn first_line_rematchgroupinforZ python_buildrget_config_varfsencodedecodeUnicodeDecodeError ValueErrorformatwrite writelines readlinescloseZ copy_filenamestatrchmod)rr updated_filesZscriptZadjustZoutfilerencodinglinesZ first_liner7Z post_interprZshebangZoutffileZoldmodeZnewmoderrrr5s                  zbuild_scripts.copy_scriptsN)r r r )r rr)rrr) __name__ __module__ __qualname__ descriptionZ user_optionsZboolean_optionsrrrrrrrrrr sr c@seZdZddZdS)build_scripts_2to3cCs&tj|\}}|js|j|||fS)N)r rr0Zrun_2to3)rrrGrrrrs zbuild_scripts_2to3.copy_scriptsN)rKrLrMrrrrrrOsrO)r(rerErZ distutilsrZdistutils.corerZdistutils.dep_utilrZdistutils.utilrrrr1compiler6r rOrrrrs