B ‘–ReKã@s‚dZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddlm Z ddlZe d ¡ZGd d „d eƒZdS) zRdistutils.command.build_scripts Implements the Distutils 'build_scripts' command.éN)ÚST_MODE)Ú sysconfig)ÚCommand)Únewer)Ú convert_path)Úlogs^#!.*python[0-9.]*([ ].*)?$c@sHeZdZdZdddgZdgZdd„Zdd „Zd d „Zd d „Z dd„Z dS)Ú build_scriptsz("build" scripts (copy and fixup #! line))z build-dir=Údzdirectory to "build" (copy) to)ÚforceÚfz1forcibly build everything (ignore file timestamps)z executable=Úez*specify final destination interpreter pathr cCs"d|_d|_d|_d|_d|_dS)N)Ú build_dirÚscriptsr Ú executableÚoutfiles)Úself©rú¡/builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/_distutils/command/build_scripts.pyÚinitialize_optionss z build_scripts.initialize_optionscCs| dddd¡|jj|_dS)NÚbuild)rr )r r )rr)Úset_undefined_optionsÚ distributionr)rrrrÚfinalize_options%s zbuild_scripts.finalize_optionscCs|jS)N)r)rrrrÚget_source_files,szbuild_scripts.get_source_filescCs|js dS| ¡dS)N)rÚ copy_scripts)rrrrÚrun/szbuild_scripts.runc Cs¾| |j¡g}g}x(|jD]}d}t|ƒ}tj |jtj |¡¡}| |¡|j spt ||ƒspt   d|¡qyt |dƒ}Wn tk rž|js–‚d}YnXXt |j¡\}}| d¡| ¡} | sÖ| d|¡qt | ¡} | röd}|  d¡pôd } |rt  d ||j¡| |¡|jstjs.|j} n(tj t d ¡d t d ¡t d¡f¡} t | ¡} d| | d} y|  d¡Wn$tk r¢t d !| ¡ƒ‚YnXy|  |¡Wn&tk rØt d !| |¡ƒ‚YnXt |dƒ}| "| ¡| #| $¡¡WdQRX|r<| %¡q|r&| %¡| |¡| &||¡qWtj'dkr¶xh|D]`}|jrlt  d|¡nDt (|¡t)d@}|dBd@}||krRt  d|||¡t *||¡qRW||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)Téózcopying and adjusting %s -> %sÚBINDIRz python%s%sÚVERSIONÚEXEs#!ó zutf-8z.The shebang ({!r}) is not decodable from utf-8zAThe shebang ({!r}) is not decodable from the script encoding ({})ÚwbÚposixzchanging mode of %siÿimz!changing mode of %s from %o to %o)+Úmkpathr rrÚosÚpathÚjoinÚbasenameÚappendr rrÚdebugÚopenÚOSErrorÚdry_runÚtokenizeÚdetect_encodingÚreadlineÚseekÚwarnÚ first_line_reÚmatchÚgroupÚinforÚ python_buildrÚget_config_varÚfsencodeÚdecodeÚUnicodeDecodeErrorÚ ValueErrorÚformatÚwriteÚ writelinesÚ readlinesÚcloseÚ copy_fileÚnameÚstatrÚchmod)rrZ updated_filesÚscriptÚadjustÚoutfiler ÚencodingÚlinesÚ first_liner5Ú post_interprÚshebangÚoutfÚfileZoldmodeZnewmoderrrr5s                  zbuild_scripts.copy_scriptsN) Ú__name__Ú __module__Ú __qualname__Ú descriptionÚ user_optionsÚboolean_optionsrrrrrrrrrrsr)Ú__doc__r&ÚrerErÚ distutilsrÚdistutils.corerÚdistutils.dep_utilrÚdistutils.utilrrr/Úcompiler4rrrrrÚs