\dXdZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z ddlmZddlZejd ZGd d eZGd 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>eZdZdZgdZdgZdZdZdZdZ dZ d S) 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 cLd|_d|_d|_d|_d|_dSN) build_dirscriptsr executableoutfilesselfs 0..\python\lib\distutils\command\build_scripts.pyinitialize_optionsz build_scripts.initialize_optionss)   cX|dddd|jj|_dS)Nbuild)r r)r r )rr)set_undefined_options distributionrrs rfinalize_optionszbuild_scripts.finalize_options%s; ""7#A#5#? A A A(0 rc|jSr)rrs rget_source_fileszbuild_scripts.get_source_files,s |rc@|jsdS|dSr)r copy_scriptsrs rrunzbuild_scripts.run/s)|  F rc R||jg}g}|jD]o}d}t|}tj|jtj|}|||j s&t||stj d| t|d}tj|j\}}|d|} | s|d|z t&| } | rd}| dpd} n#t,$r |jsd }YnwxYw|rtjd ||j|||jst2js|j} n[tjt3jd d t3jd t3jd} t j| } d| z| zdz} | dn0#t>$r#tAd!| wxYw | |n1#t>$r$tAd!| |wxYwt|d5}|"| |#|$d d d n #1swxYwY|r|%.|r|%|||&||qtj'dkr~|D]{}|jrtjd|t j(|tRdz}|dzdz}||kr,tjd|||t j*|||||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)rbrz%s is an empty file (skipping)TrNzcopying and adjusting %s -> %sBINDIRpythonVERSIONEXEs#! 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 rr debugopentokenizedetect_encodingreadlineseekwarn first_line_rematchgroupOSErrordry_runinfor python_buildrget_config_varfsencodedecodeUnicodeDecodeError ValueErrorformatwrite writelines readlinesclose copy_filenamestatrchmod)rr updated_filesscriptadjustoutfilerencodinglines first_liner= post_interprshebangoutffileoldmodenewmodes rr#zbuild_scripts.copy_scripts5s DN### lL 0L 0FF!&))Fgll4>273C3CF3K3KLLG OOG $ $ $: eFG&<&<  7@@@  8&& #+":1:"F"F%q ZZ\\ !II>GHHH%++J778!F"'++a.."7CK   | ", 096)))$$W---|!7$1M%)_ %'W\\%4X>>>+4+CI+N+N+N+4+CE+J+J+JL&M&M "$Z!8!8J#j0;>FG :w////-:::())/::::8x0000-888(<#VGX668888 gt,,7 7+++ 666777777777777777GGIIIGGIII$$W---vw//// 7g   0 0<0H2D9999 gdmmG4v=G&&8G'))!D!%w999w///&&s<?E&&E=<E= I  -J J''.K(=L11L5 8L5 N) __name__ __module__ __qualname__ description user_optionsboolean_optionsrrr!r$r#rrr r s>K   L iO111 c'c'c'c'c'rr ceZdZdZdS)build_scripts_2to3c|t|\}}|js||||fSr)r r#r@run_2to3)rrrQs rr#zbuild_scripts_2to3.copy_scriptssA"/"<"rps55 """"""$$$$$$22222222 ;<< G'G'G'G'G'GG'G'G'R''''' '''''r