Re8E ddlmZddlZddlZddlZddlZddlZddlmZm Z m Z ddl m Z ddl mZmZmZmZmZmZejeZdZejdZd Zd ZeZGd d eZdS) )BytesION) sysconfigdetect_encodingZipFile)finder) FileOperatorget_export_entry convert_pathget_executable get_platformin_venva s^#!.*pythonw?[0-9.]*([ ].*)?$z# -*- coding: utf-8 -*- import re import sys from %(module)s import %(import_name)s if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(%(func)s()) cd|vrj|dr;|dd\}}d|vr|ds|d|d}n|dsd|z}|S)N z /usr/bin/env r"z "z"%s") startswithsplit) executableenv _executables /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/distlib/scripts.pyenquote_executabler3s j   1 1 1)//Q77 Ck!!+*@*@*E*E!*-##{{{; ((-- 1#j0 c6eZdZdZeZdZ ddZdZe j drdZ d Z d Zdd Zd ZeZdZdZdZdZddZdZedZejdZejdksejdkrejdkrdZddZ ddZ!dS) ScriptMakerz_ A class to copy or create scripts from source scripts or callable specifications. NTFc||_||_||_d|_d|_t jdkpt jdkot jdk|_td|_ |pt||_ t jdkpt jdkot jdk|_ tj|_dS)NFposixjava)X.Ynt) source_dir target_dir add_launchersforceclobberosname_nameset_modesetvariantsr _fileop_is_ntsys version_info)selfr"r#r$dry_runfileops r__init__zScriptMaker.__init__Ns$$*  G+FF1B2E13W1D K(( 6g!6!6 go4 Gv  2"(d"2 ,rc|ddr_|jrXtj|\}}|dd}tj||}|S)NguiFpythonpythonw)getr.r'pathrreplacejoin)r1roptionsdnfns r_get_alternate_executablez%ScriptMaker._get_alternate_executable_sf ;;ue $ $ . .W]]:..FBHi00Bb"--Jrrc t|5}|ddkcdddS#1swxYwYdS#ttf$rtd|YdSwxYw)zl Determine if the specified executable is a script (contains a #! line) z#!NzFailed to open %sF)openreadOSErrorIOErrorloggerwarning)r1rfps r _is_shellzScriptMaker._is_shellgs  *%%.771::-..................W%   2J???uu s,A7 A;A;A,A43A4c||r*ddl}|jjddkr|Sn)|dr|Sd|zS)Nrzos.nameLinuxz jython.exez/usr/bin/env %s)rJrlangSystem getPropertylowerendswith)r1rrs r_fix_jython_executablez"ScriptMaker._fix_jython_executabless|~~j)) " 9#// ::gEE%%F!!##,,\:: "!!$z1 1rctjdkrd}nAt|t|zdz}tjdkrd}nd}d|vo||k}|r d|z|zd z}nd }|d |z|zd zz }|d z }|S)a Build a shebang line. In the simple case (on Windows, or a shebang line which is not too long or contains spaces) use a simple formulation for the shebang. Otherwise, use /bin/sh as the executable, with a contrived shebang which allows the script to run either under Python or sh, using suitable quoting. Thanks to Harald Nordgren for his input. See also: http://www.in-ulm.de/~mascheck/various/shebang/#length https://hg.mozilla.org/mozilla-central/file/tip/mach rTdarwini s#! s #!/bin/sh s '''exec' s "$0" "$@" s' ''')r'r(lenr/platform)r1r post_interpsimple_shebangshebang_lengthmax_shebang_lengthresults r_build_shebangzScriptMaker._build_shebangs 7g  !NN!__s;/?/??!CN|x''%(""%("#:5E-1CC   Z'+5=FF#F lZ/+=O OF h F rrcd}|jr |j}d}n:tjst}nt rHt jtjddtj dz}nt jtj ddtj dtj d}t j |sGt jtj ddtj dz}|r| ||}tj d r||}|rt!|}|d }tj d kr d |vr d |vr|dz }|||} |d n #t($rt+d|zwxYw|d kr; ||n$#t($rt+d|d|dwxYw|S)NTFscriptszpython%sEXEBINDIRr7VERSIONrutf-8cliz -X:Framesz -X:FullFramess -X:Framesz,The shebang (%r) is not decodable from utf-8z The shebang (z-) is not decodable from the script encoding ())rris_python_buildr rr'r:r<get_pathget_config_varisfiler@r/rZrrRrencoder`decodeUnicodeDecodeError ValueError)r1encodingr[r=enquotershebangs r _get_shebangzScriptMaker._get_shebangs ? PJGG*,, P'))JJ YY Pi&8&C&C&)A%)H)HHJJJJ(222(7 BBB(7>>>@AAJ7>>*-- P W\\)*B8*L*L *i.Fu.M.M NPP  M77 GLLJ < " "6 * * A44Z@@J  8+J77J &&w// LE ! !k&D&D{22 = (K%%j+>>  J NN7 # # # #! J J J>HJJ J J w   Kx((((% K K K j7>wwJKKK Ks5H H(2I!I)c|jt|j|jdd|jzS)N.r)module import_namefunc)script_templatedictprefixsuffixr)r1entrys r_get_script_textzScriptMaker._get_script_textsD#d%,7<|7I7I#7N7Nq7Q05 '>'>'>> >rcTtj|}|j|zSN)r'r:basenamemanifest)r1exenamebases r get_manifestzScriptMaker.get_manifests$w((}t##rc|jo|j}tjd}||s||z }|s||z}n|dkr|d}n|d}t} t| d5} | d|dddn #1swxYwY| } ||z| z}|D]} tj |j | } |r.tj | \}}|dr|} d| z} |j| |nx#t$$rt&dd | z}tj |rtj|tj| ||j| |t&d  tj|n#t$$rYnwxYwYnwxYw|jr| d |zs| d |} tj | r$|jst&d | |j| ||jr|j| g|| dS) Nrfpytwz __main__.pyz.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz %s.deletemez0Able to replace executable using .deleteme logicrvzSkipping existing file %s)r$r.r'lineseprmrQ _get_launcherrrwritestrgetvaluer:r<r#splitextrr-write_binary_file ExceptionrGrHexistsremoverenamedebugr&r*set_executable_modeappend)r1namesrs script_bytes filenamesext use_launcherrlauncherstreamzfzip_datar(outnamenedfnames r _write_scriptzScriptMaker._write_scriptsa)9dk *##G,,((  w G 9"\1LLd{{--c22--c22YYF%% 9 M<888 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9((H#g-8L! &! &Dgll4?D99G @w''001<<&& G"W,L227LIIII NN$9:::*W4Fw~~f--* &)))Igv...L227LIIILL"3444 &))))$ ;7w'7'7c 'B'B7)0##6G7>>'**4<NN#>HHH ..w EEE=@L44gY???   W % % % %C! &! &sICC CE22B&IH.-I. H;8I:H;;II-c<t}d|jvr||d|jvr$|||jdd|jvr9|||j|jdd|jd|S)NrXrr rvr)r+r,addr0variant_separator)r1r(r_s rget_script_filenamesz ScriptMaker.get_script_filenames$s    JJt    $-   JJt'8';';< = = = DM ! ! JJddD,B,B&*&7&:&:&:D %srspythonwrr) r'r:r<r"r r#rr%r-newerrGrrCreadlinerH FIRST_LINE_REmatchr;grouprFr2close copy_filer*rrinforseekrtrrD)r1rradjustrf first_linerr[rqlinesrsrrs r _copy_scriptzScriptMaker._copy_script?sdo|F/C/CDD',,t0@0@0H0HIIz $,"4"4VW"E"E  LL6 ? ? ? F  4VT""A J ?HHH!'' (:(:7E(J(JKKE 4#kk!nn3    < AAA    L " "67 3 3 3} < 00';;;   W % % % % % KK8& ) ) )<' K"1!*"="=%q ++HkBB++CCCG$$W--""A39cJJJ    s7EEEc|jjSrr-r2)r1s rr2zScriptMaker.dry_runrs |##rc||j_dSrr)r1values rr2zScriptMaker.dry_runvs$ rr!c@tjddkrd}nd}tdkrdnd}|||d}td d d }t ||}|sd |d |}t||jS)NP6432z win-arm64z-armrz.exervrrzUnable to find resource z in package ) structcalcsizer __name__rsplitrfindrpbytes)r1kindbitsplatform_suffixr(distlib_packageresourcemsgs rrzScriptMaker._get_launcher~ss##q(((4+(E(Eff2O#'4?D'ooc155a8Oo..33D99H & &EITT&( oo%> !rcg}t|}||||n|||||S)a Make a script. :param specification: The specification, which is either a valid export entry specification (to make a script from a callable) or a filename (to make a script by copying from a source location). :param options: A dictionary of options controlling script generation. :return: A list of all absolute pathnames written to. Nr)r rr)r1 specificationr=rr~s rmakezScriptMaker.makesU  // =   mY 7 7 7 7   eY  @ @ @rcfg}|D]+}||||,|S)z Take a list of specifications and make scripts from them, :param specifications: A list of specifications. :return: A list of all absolute pathnames written to, )extendr)r1specificationsr=rrs r make_multiplezScriptMaker.make_multiplesE  + @ @M   TYY}g>> ? ? ? ?r)TFN)rNr)"r __module__ __qualname____doc__SCRIPT_TEMPLATErzrr4r@r/rZrrJrRr`rtr_DEFAULT_MANIFESTrrrrrrrpropertyr2setterr'r(r)rrrrrrrEs&OJ=A'+----" |v&&2    2 2 2>CCCCJ>>> !H$$$2&2&2&h   IIII 111f$$X$ ^%%^% w$27f,,T1A1A " " "&&      rr) iorloggingr'rerr/compatrrr resourcesrutilr r r r r r getLoggerrrGstriprcompilerrr_enquote_executableobjectrrrrrs_ 7777777777::::::::::::::::  8 $ $ uww!& =>>     )hhhhh&hhhhhr