gHPddlmZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z ddlmZddlmZmZmZmZmZmZej.eZdj5Zej8d Zd Zej>d k(sej>d k(ryej@d k(rjejCd ddZ"ee"jGdDcic]4}|j>jIdr|j>|jJ6c}Z&dZ'e'Z(Gdde)Z*ycc}w))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()) ntjava..execd|vr[|jdr4|jdd\}}d|vr|jds|d|d}|S|jdsd|z}|S)N z /usr/bin/env r"z "z"%s") startswithsplit) executableenv _executables >/opt/hc_python/lib/python3.12/site-packages/distlib/scripts.pyenquote_executablerGsx j   1)//Q7 Ck!+*@*@*E*-{;  ((-#j0 cHeZdZdZeZdZddZdZe 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)NFposixr)rX.Yr) source_dir target_dir add_launchersforceclobberosname_nameset_modesetvariantsr _fileop_is_ntsys version_info)selfr%r&r'dry_runfileops r__init__zScriptMaker.__init__ds$$*  G+[F1B1ZrxxSZGZ K( 6g!6 ggoQ"''V*;*PD@P ,,rc|jddr`|jrTtjj |\}}|j dd}tjj ||}|S)NguiFpythonpythonw)getr1r*pathrreplacejoin)r4roptionsdnfns r_get_alternate_executablez%ScriptMaker._get_alternate_executablersV ;;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)r4rfps r _is_shellzScriptMaker._is_shell{sR  *%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)rMrlangSystem getPropertylowerendswith)r4rrs r_fix_jython_executablez"ScriptMaker._fix_jython_executablesk~~j)99##// :gE%%%z1 1!!#,,\:!!$z1 1rctjdk7rd}nQttddrd}n=t |t |zdz}tj dk(rd}nd}d |vxr||k}|r d |z|zd z}|Sd }|d |z|zdzz }|dz }|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 r#Tcross_compilingFdarwini s#! s #!/bin/sh s '''exec' s "$0" "$@" s' ''' )r*r+getattrr2lenplatform)r4r post_interpsimple_shebangshebang_lengthmax_shebang_lengthresults r_build_shebangzScriptMaker._build_shebangs 77g !N S+U 3 #N!_s;/??!CN||x'%("%("#:5aNN`<`N Z'+5=F  $F lZ/+=O OF j F rcd}|jr|j}d}n/tjs t}nt rJt j jtjddtjdz}nt jdk(rJt j jtjddtjdz}n^t j jtjddtjd tjd}|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%sEXErBINDIRr:VERSIONrutf-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_varr+rCr2r_rrUrencoderedecodeUnicodeDecodeError ValueError)r4encodingr`r@enquotershebangs r _get_shebangzScriptMaker._get_shebangs ??JG**,')J Yi&8&8&CZR[RjRjkpRqEqrJww$ WW\\)*B*B8*L*4 8P8PQV8W*XZ  WW\\,,X6$-$<$  W NN7 # w  Xx(w" WKgUV V W& X DKX"WXX Xs#H:H*H'*Ic|jt|j|jj dd|jzS)Nrr)module import_namefunc)script_templatedictprefixsuffixr)r4entrys r_get_script_textzScriptMaker._get_script_textsB##d<>'*4<<NN#>H ..w E==LL44gY?   W %C&%&!NN$9:*W4Fww~~f- &)IIgv.LL227LILL"34 &)$sD!A5I#II BL.LL L LLLL-cPt}d|jvr|j|d|jvr"|j||jdd|jvr>|j||j|jdd|jd|S)NrXrr$rr)r.r/addr3variant_separator)r4r+rds rget_script_filenamesz ScriptMaker.get_script_filenames<s   JJt  $--  JJt'8'8';< = DMM ! JJdD,B,BDDUDUVWDXZ^ZkZklmZno p rcxd}|r9|jdg}|r%ddj|z}|jd}|jd||}|j |jd}|j |j }|r|jddrd } nd } |j||||| y) Nrinterpreter_argsz %srrkr@r9Fpywr)r<r?rqrxrrr+r) r4rrr@r`argsrwscript scriptnamesrs r _make_scriptzScriptMaker._make_scriptFs ;;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 r\Trrzcopying and adjusting %s -> %srspythonwrr) r*r=r?r%r r&rr(r0newerrJrrFreadlinerK FIRST_LINE_REmatchr>grouprIr5close copy_filer-rrinforseekrxrrG)r4rradjustrf first_linerr`rulinesrwrrs r _copy_scriptzScriptMaker._copy_scriptVsdoo|F/CD'',,t0@0@0HIzz$,,"4"4VW"E LL6 ?   4VT"A J?H!'' (:(:7E(JKE#kk!n3  LL " "67 3}} 00';   W % KK8&$// R<<''"1!**"=%q ++HkB+CCGG$$W-""A39cJ E <<A s= I--J J c.|jjSrr0r5)r4s rr5zScriptMaker.dry_runs||###rc&||j_yrr)r4values rr5zScriptMaker.dry_runs$ rrctjddk(rd}nd}tdk(rdnd}|||d}|tvrd |d t}t |t|S) NP6432z win-arm64z-armrrzUnable to find resource z in package )structcalcsizerWRAPPERSDISTLIB_PACKAGErt)r4kindbitsplatform_suffixr+msgs rrzScriptMaker._get_launchersas#q((4+(Ef2O#'?D8#o/ o%D> !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)r4 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)r4specificationsr@rrs r make_multiplezScriptMaker.make_multiples2  +M   TYY}g> ?,r)TFN)rNr)"__name__ __module__ __qualname____doc__SCRIPT_TEMPLATEr}rr7rCr2r_rrMrUrerxr_DEFAULT_MANIFESTrrrrrrrpropertyr5setterr*r+r,rrrrrr!r![s&OJ - ||v&  2"H@D\!H$5&nI 0d$$ ^^%% ww$277f,T1A "& rr!)+iorloggingr*rerr2rzipfilercompatrrr resourcesr utilr r r r rr getLoggerrrJstriprcompilerrr+r,rsplitriteratorrTbytesrr_enquote_executableobjectr!)rs0rrs 77gg   8 $ uw!& => "77d?rww&(RXX-=ooc1-a0O(11"55A 66??6 " 5H ")d&d7s9D#