VULN_CHECK_I913V6 jFddlmZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z ddlmZddlmZmZmZmZmZmZej.eZdj5Zej8d Zd Zd ZeZ Gd d e!Z"y))BytesION)ZipInfo) 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|vr[|jdr4|jdd\}}d|vr|jds|d|d}|S|jdsd|z}|S)N z /usr/bin/env r"z "z"%s") startswithsplit) executableenv _executables @/usr/lib/python3.12/site-packages/pip/_vendor/distlib/scripts.pyenquote_executabler5sx j   1)//Q7 Ck!+*@*@*E*-{;  ((-#j0 cLeZdZdZeZdZ ddZdZe jjdrdZ dZ dZdd Zd ZeZd Zd Zd ZdZddZdZedZej6dZej:dk(sej:dk(rej<dk(rdZddZ ddZ!y) ScriptMakerz_ A class to copy or create scripts from source scripts or callable specifications. Nc||_||_||_d|_d|_t j dk(xs(t j dk(xrt jdk(|_td|_ |xs t||_ t j dk(xs(t j dk(xrt jdk(|_ tj|_y)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__Ps$$*  G+FF1B2E13W1D K( 6g!6 ggo4 GGv  2"((d"2 ,,rc|jddr`|jrTtjj |\}}|j dd}tjj ||}|S)NguiFpythonpythonw)getr/r(pathrreplacejoin)r2roptionsdnfns r_get_alternate_executablez%ScriptMaker._get_alternate_executableasV ;;ue $WW]]:.FBHi0Bb"-Jrrc t|5}|jddk(cdddS#1swYyxYw#ttf$rtj d|YywxYw)zl Determine if the specified executable is a script (contains a #! line) z#!NzFailed to open %sF)openreadOSErrorIOErrorloggerwarning)r2rfps r _is_shellzScriptMaker._is_shellisR  *%771:-&%%W% 2J? s# 7+ 7477%AAc|j|r3ddl}|jjj ddk(r|Sd|zS|j j dr|Sd|zS)Nrzos.nameLinuxz jython.exez/usr/bin/env %s)rKrlangSystem getPropertylowerendswith)r2rrs r_fix_jython_executablez"ScriptMaker._fix_jython_executableusk~~j)99##// :gE%%%z1 1!!#,,\:!!$z1 1rctjdk7rd}n=t|t|zdz}tjdk(rd}nd}d|vxr||k}|r d|z|zd z}|Sd }|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)lenr0platform)r2r post_interpsimple_shebangshebang_lengthmax_shebang_lengthresults r_build_shebangzScriptMaker._build_shebangs 77g !N!_s;/??!CN||x'%("%("#:5E-1CC  Z'+5=F  $F lZ/+=O OF h F rcd}|jr|j}d}n:tjs t}nt rJt j jtjddtjdz}nt j jtjddtjdtjd}t j j|sIt j jtjddtjdz}|r|j||}tjjd r|j|}|r t!|}|j#d }tjd k(r d |vr d |vr|dz }|j%||} |j'd |d k7r |j'||S|S#t($rt+d|zwxYw#t($rt+d|d|dwxYw)NTFscriptszpython%sEXEBINDIRr8VERSIONrutf-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_varisfilerAr0r[rrSrencoderadecodeUnicodeDecodeError ValueError)r2encodingr\r>enquotershebangs r _get_shebangzScriptMaker._get_shebangs ??JG**,')J Yi&8&8&C&)A)A%)HHJJ((2(77 B(77>@AJ77>>*- WW\\)*B*B8*L *i.F.Fu.M NP 77 GLJ << " "6 *44Z@J +J7J &&w/ LLE !k&D{2 = (K%%j+>  J NN7 # w  Kx( w" J>HJ J J& K 7>JKK Ks.HH5H25Ic|jt|j|jj dd|jzS)N.r)module import_namefunc)script_templatedictprefixsuffixr)r2entrys r_get_script_textzScriptMaker._get_script_texts@##d%,,7<||7I7I#7Nq7Q05 '>> >rc^tjj|}|j|zSN)r(r;basenamemanifest)r2exenamebases r get_manifestzScriptMaker.get_manifests%ww(}}t##rc|jxr |j}tjj d}|j |s||z }|s||z}n|dk(r|j d}n|j d}t} t| d5} tjjd} | rAtjt| dd} td| } | j| |n| jd|ddd| j!}||z|z}|D]E}tj"j%|j&|}|rXtj"j)|\}}|j+d r|}d |z} |j,j/||n|jr|j d|zs|d|}tj"j7|r#|j>st2j5d||j,j/|||j@r|j,jC|g|jE|Hy#1swYnxYw#t0$rt2j5d d |z}tj"j7|rtj8|tj:|||j,j/||t2j=d  tj8|n#t0$rYnwxYwYwxYw)NrgpytwSOURCE_DATE_EPOCHz __main__.py)filename date_timez.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz %s.deletemez0Able to replace executable using .deleteme logicrwzSkipping existing file %s)#r%r/r(lineseprnrR _get_launcherrrenvironr:timegmtimeintrwritestrgetvaluer;r=r$splitextrr.write_binary_file ExceptionrHrIexistsremoverenamedebugr'r+set_executable_modeappend)r2namesrt script_bytes filenamesext use_launcherrlauncherstreamzfsource_date_epochrzinfozip_datar)outnamenedfnames r _write_scriptzScriptMaker._write_scripts))9dkk **##G,( w G"\1Ld{--c2--c2YF%$&JJNN3F$G!$ $ C0A,B CBQ GI#]iPEKK|4KK |<&(H#g-8LDggll4??D9Gww''01<<&G"W,LL227LI";;w'7'7c 'B)0#6G77>>'*4<<NN#>H ..w E==LL44gY?   W %C&%&!NN$9:*W4Fww~~f- &)IIgv.LL227LILL"34 &)$sDA5I7J7JBM #L98M 9 MM MM  M -cPt}d|jvr|j|d|jvr"|j||jdd|jvr>|j||j|jdd|jd|S)Nr Xrr!rwr)r,r-addr1variant_separator)r2r)r`s rget_script_filenamesz ScriptMaker.get_script_filenames,s   JJt  $--  JJt'8'8';< = DMM ! JJdD,B,B&*&7&7&:Dr7Fpywr)r:r=rnrurrr)r) r2rrr>r\argsrtscript scriptnamesrs r _make_scriptzScriptMaker._make_script7s ;;126Dsxx~-"kk'2 ##G['#J&&u-44W=// ; w{{5%0CC ;CHrcd}tjj|jt |}tjj|j tjj |}|js3|jj||stjd|y t|d}|j}|stjd|ytj!|j#dd}|rd}|j%dxsd } |sh|r|j+|jj-|||j.r|jj1|g|j3|ytj5d ||j |jj(st7|j\} } |j9d |j;| } d vrd } nd} tjj |} |j=| g| |j?|| |r|j+yy#t&$r|j(sd}YWwxYw)NFznot copying %s (up-to-date)rbz%s is an empty file (skipping)s rYTrrzcopying and adjusting %s -> %srspythonwrr) r(r;r=r#r r$rr&r.newerrHrrDreadlinerI FIRST_LINE_REmatchr<grouprGr3close copy_filer+rrinforseekrurrE)r2rradjustrf first_linerr\rrlinesrtrrs r _copy_scriptzScriptMaker._copy_scriptGsdoo|F/CD'',,t0@0@0HIzz$,,"4"4VW"E LL6 ?   4VT"A J?H!'' (:(:7E(JKE#kk!n3  LL " "67 3}} 00';   W % KK8& )<<''"1!**"=%q ++HkB+CCGG$$W-""A39cJ G <<A s= I--J J c.|jjSrr.r3)r2s rr3zScriptMaker.dry_runzs||###rc&||j_yrr)r2values rr3zScriptMaker.dry_run~s$ rr"ctjddk(rd}nd}tdk(rdnd}|||d}tj d d d }t |j |}|sd |d |}t||jS)NP6432z win-arm64z-armr z.exerwrrzUnable to find resource z in package ) structcalcsizer__name__rsplitr findrqbytes)r2kindbitsplatform_suffixr)distlib_packageresourcemsgs rrzScriptMaker._get_launcherss#q((4+(Ef2O#'?D'ooc15a8Oo.33D9HEI&( o%>> !rctg}t|}||j|||S|j||||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. r)r rr)r2 specificationr>rrs rmakezScriptMaker.makesM  / =   mY 7   eY  @rcZg}|D]#}|j|j||%|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)r2specificationsr>rrs r make_multiplezScriptMaker.make_multiples2  +M   TYY}g> ?,r)TFN)rNr)"r __module__ __qualname____doc__SCRIPT_TEMPLATEr{rr5rAr0r[rrKrSrarur_DEFAULT_MANIFESTrrrrrrrpropertyr3setterr(r)r*rrrrrrrGs&OJ=A'+-" ||v&  2>CJ> !H$8&t I 1f$$ ^^%% ww$277f,T1A "&& rr)#iorloggingr(rerr0rzipfilercompatrrr resourcesr utilr r r r rr getLoggerrrHstriprcompilerrr_enquote_executableobjectrrrrrs 77::   8 $ uw!& =>   )n&nr