
    fXfF                         d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 ddl
mZmZmZ ddlmZ ddlmZmZmZmZmZmZ  ej        e          Zd                                Z ej        d	          Zd
Zd ZeZ  G d de!          Z"dS )    )BytesION)ZipInfo   )	sysconfigdetect_encodingZipFile)finder)FileOperatorget_export_entryconvert_pathget_executableget_platformin_venva  
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <assemblyIdentity version="1.0.0.0"
 processorArchitecture="X86"
 name="%s"
 type="win32"/>

 <!-- Identify the application security requirements. -->
 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
 <security>
 <requestedPrivileges>
 <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
 </requestedPrivileges>
 </security>
 </trustInfo>
</assembly>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())
c                     d| v rj|                      d          r;|                     dd          \  }}d|v r|                     d          s|d|d} n|                      d          sd| z  } | S )N z/usr/bin/env r   "z "z"%s")
startswithsplit)
executableenv_executables      T/var/www/html/Qu*py/bism/lib/python3.11/site-packages/pip/_vendor/distlib/scripts.pyenquote_executabler   5   s    
j
   11 	1)//Q77Ck!!+*@*@*E*E!*-##{{{;
((-- 1#j0
    c                   6   e Zd ZdZeZdZ	 	 ddZd Ze	j
                            d          rd Zd	 Zd
 ZddZd ZeZd Zd ZdZd ZddZd Zed             Zej        d             Zej        dk    sej        dk    rej        dk    rd ZddZ ddZ!dS )ScriptMakerz_
    A class to copy or create scripts from source scripts or callable
    specifications.
    NTFc                    || _         || _        || _        d| _        d| _        t
          j        dk    pt
          j        dk    ot
          j        dk    | _        t          d          | _
        |pt          |          | _        t
          j        dk    pt
          j        dk    ot
          j        dk    | _        t          j        | _        d S )NFposixjava) X.Ynt)
source_dir
target_diradd_launchersforceclobberosname_nameset_modesetvariantsr
   _fileop_is_ntsysversion_info)selfr#   r$   r%   dry_runfileops         r   __init__zScriptMaker.__init__P   s    $$*
G+ FF1B 2E13W1D 	K((6g!6!6go 4Gv2"(d"2 	,r   c                     |                     dd          r_| j        rXt          j                            |          \  }}|                    dd          }t          j                            ||          }|S )NguiFpythonpythonw)getr/   r(   pathr   replacejoin)r2   r   optionsdnfns        r   _get_alternate_executablez%ScriptMaker._get_alternate_executablea   sf    ;;ue$$ 	. 	.W]]:..FBHi00Bb"--Jr   r   c                     	 t          |          5 }|                    d          dk    cddd           S # 1 swxY w Y   dS # t          t          f$ r t                              d|           Y dS w xY w)zl
            Determine if the specified executable is a script
            (contains a #! line)
               z#!NzFailed to open %sF)openreadOSErrorIOErrorloggerwarning)r2   r   fps      r   	_is_shellzScriptMaker._is_shelli   s    
*%% .771::-. . . . . . . . . . . . . . . . . .W%   2J???uus,   A 7A ;A ;A ,A43A4c                     |                      |          r*dd l}|j        j                            d          dk    r|S n)|                                                    d          r|S d|z  S )Nr   zos.nameLinuxz
jython.exez/usr/bin/env %s)rK   r   langSystemgetPropertylowerendswith)r2   r   r   s      r   _fix_jython_executablez"ScriptMaker._fix_jython_executableu   s|    ~~j)) "9#//	::gEE%% F!!##,,\:: "!!$z11r   c                     t           j        dk    rd}nAt          |          t          |          z   dz   }t          j        dk    rd}nd}d|vo||k    }|rd|z   |z   d	z   }nd
}|d|z   |z   dz   z  }|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
        r   T   darwini          s   #!   
s
   #!/bin/sh
s	   '''exec' s    "$0" "$@"
s   ' ''')r(   r)   lenr0   platform)r2   r   post_interpsimple_shebangshebang_lengthmax_shebang_lengthresults          r   _build_shebangzScriptMaker._build_shebang   s     7g!NN !__s;/?/??!CN|x''%(""%("#:5 E-1CC   	Z'+5=FF#FlZ/+=OOFhFr   r   c                    d}| j         r| j         }d}n:t          j                    st                      }nt	                      rHt
          j                            t          j        d          dt          j	        d          z            }nt
          j                            t          j	        d          dt          j	        d          t          j	        d                    }t
          j        
                    |          sGt
          j                            t          j	        d          dt          j	        d          z            }|r|                     ||          }t          j                            d	          r|                     |          }|rt!          |          }|                    d
          }t          j        dk    rd|vr	d|vr|dz  }|                     ||          }	 |                    d
           n # t(          $ r t+          d|z            w xY w|d
k    r;	 |                    |           n$# t(          $ r t+          d|d|d          w xY w|S )NTFscriptszpython%sEXEBINDIRr8   VERSIONr   utf-8cliz	-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 ())r   r   is_python_buildr   r   r(   r;   r=   get_pathget_config_varisfilerA   r0   r[   r   rS   r   encodera   decodeUnicodeDecodeError
ValueError)r2   encodingr\   r>   enquoter   shebangs          r   _get_shebangzScriptMaker._get_shebang   s   ? 	PJGG*,, 	P'))JJYY 	Pi&8&C&C&)A%)H)HHJ JJJ (222(7	BBB(7>>>@A AJ 7>>*-- P  W\\)*B8*L*L *i.Fu.M.M NP P
 	M77
GLLJ<""6** 	A44Z@@J  	8+J77J  &&w//
LE!!k&D&D{22=(K%%j+>>	JNN7####! 	J 	J 	J>HJ J J	J wKx((((% K K K j7>wwJK K KK s   5H H(2I !I)c                     | j         t          |j        |j                            d          d         |j                  z  S )N.r   )moduleimport_namefunc)script_templatedictprefixsuffixr   )r2   entrys     r   _get_script_textzScriptMaker._get_script_text   sD    #d%,7<|7I7I#7N7Nq7Q05'> '> '> > 	>r   c                 T    t           j                            |          }| j        |z  S N)r(   r;   basenamemanifest)r2   exenamebases      r   get_manifestzScriptMaker.get_manifest   s$    w((}t##r   c                    | j         o| j        }t          j                            d          }|                    |          s||z  }|s||z   }n|dk    r|                     d          }n|                     d          }t                      }	t          |	d          5 }
t          j	        
                    d          }|rQt          j        t          |                    d d         }t          d|          }|
                    ||           n|
                    d|           d d d            n# 1 swxY w Y   |	                                }||z   |z   }|D ]}t          j                            | j        |          }|r.t          j                            |          \  }}|                    d	          r|}d
|z  }	 | j                            ||           nx# t0          $ r t2                              d           d|z  }t          j                            |          rt          j        |           t          j        ||           | j                            ||           t2                              d           	 t          j        |           n# t0          $ r Y nw xY wY nw xY w| j        r|                    d|z             s|d|}t          j                            |          r$| j        st2                              d|           | j                            ||           | j         r| j        !                    |g           |"                    |           d S )Nrg   pytwSOURCE_DATE_EPOCH   z__main__.py)filename	date_timez.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz%s.deletemez0Able to replace executable using .deleteme logicrw   zSkipping existing file %s)#r%   r/   r(   lineseprn   rR   _get_launcherr   r   environr:   timegmtimeintr   writestrgetvaluer;   r=   r$   splitextr   r.   write_binary_file	ExceptionrH   rI   existsremoverenamedebugr'   r+   set_executable_modeappend)r2   namesrt   script_bytes	filenamesextuse_launcherr   launcherstreamzfsource_date_epochr   zinfozip_datar)   outnamenedfnames                       r   _write_scriptzScriptMaker._write_script   s   )9dk*##G,,(( 	wG 	9"\1LLd{{--c22--c22YYF%% =$&JNN3F$G$G!$ = $C0A,B,B C CBQB GI#]iPPPEKK|4444KK|<<<= = = = = = = = = = = = = = = ((H#g-8L !	& !	&Dgll4?D99G @w''001<<&&  G"W,L227LIIII    NN $9 : : :*W4Fw~~f-- *	&)))Igv...L227LIIILL "3 4 4 4	&))))$     ; 7w'7'7c	'B'B 7)0##6G7>>'** 4< NN#>HHH..wEEE= @L44gY???W%%%%C!	& !	&sJ    B	D55D9<D9G%%B&J4J! J4!
J.+J4-J..J43J4-c                 <   t                      }d| j        v r|                    |           d| j        v r$|                    || j        d                    d| j        v r9|                    || j        | j        d         d| j        d                    |S )Nr    Xr   r!   rw   r   )r,   r-   addr1   variant_separator)r2   r)   r`   s      r   get_script_filenamesz ScriptMaker.get_script_filenames,  s    JJt$-JJt'8';';<===DM!!JJddD,B,B&*&7&:&:&:D<Ma<P<PR S S Sr   c                    d}|rE|                     dg           }|r-dd                    |          z  }|                    d          }|                     d||          }|                     |                              d          }|                     |j                  }|r|                     dd          rd	}	nd
}	|                     |||||	           d S )Nr   interpreter_argsz %sr   rg   r>   r7   Fpywr   )r:   r=   rn   ru   r   r   r)   r   )
r2   r   r   r>   r\   argsrt   scriptscriptnamesr   s
             r   _make_scriptzScriptMaker._make_script7  s     	3;;1266D 3sxx~~-"kk'22##G['#JJ&&u--44W==//
;; 	w{{5%00 	CCC;CHHHHHr   c                 N   d}t           j                            | j        t	          |                    }t           j                            | j        t           j                            |                    }| j        s8| j        	                    ||          st                              d|           d S 	 t          |d          }|                                }|st                              d|           d S t                              |                    dd                    }|rd}|                    d          pd	}n# t&          $ r | j        s d }Y nw xY w|sj|r|                                 | j                            ||           | j        r| j                            |g           |                    |           d S t                              d
|| j                   | j        j        st7          |j                  \  }	}
|                    d           |                     |	|          }d|v rd}nd}t           j                            |          }|                     |g||                                ||           |r|                                 d S d S )NFznot copying %s (up-to-date)rbz%s is an empty file (skipping)s   
rY   Tr   r   zcopying and adjusting %s -> %sr   s   pythonwr   r   ) r(   r;   r=   r#   r   r$   r   r&   r.   newerrH   r   rD   readlinerI   FIRST_LINE_REmatchr<   grouprG   r3   close	copy_filer+   r   r   infor   seekru   r   rE   )r2   r   r   adjustr   f
first_liner   r\   rr   linesrt   r   r   s                 r   _copy_scriptzScriptMaker._copy_scriptG  s   do|F/C/CDD',,t0@0@0H0HIIz 	$,"4"4VW"E"E 	LL6???F
	4VT""A J ?HHH!''
(:(:7E(J(JKKE 4#kk!nn3  	 	 	< AAA	  	 			L""67333} <00';;;W%%%%%KK8&) ) )<' 	K"1!*"="=%q			++HkBB++CCCG$$W--""A39cJJJ 					 s   7E EEc                     | j         j        S r   r.   r3   )r2   s    r   r3   zScriptMaker.dry_runz  s    |##r   c                     || j         _        d S r   r   )r2   values     r   r3   zScriptMaker.dry_run~  s    $r   r"   c                 @   t          j        d          dk    rd}nd}t                      dk    rdnd}|||d}t                              d	d
          d         }t          |                              |          }|sd|d|}t          |          |j        S )NP   6432z	win-arm64z-armr    z.exerw   r   r   zUnable to find resource z in package )	structcalcsizer   __name__rsplitr	   findrq   bytes)r2   kindbitsplatform_suffixr)   distlib_packageresourcemsgs           r   r   zScriptMaker._get_launcher  s    s##q(((4+(E(Eff2O#'4?D 'ooc155a8Oo..33D99H & &EITT&( oo%>!r   c                     g }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   r   r   )r2   specificationr>   r   r   s        r   makezScriptMaker.make  sU     	 //=mY7777eY@@@r   c                 f    g }|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   )r2   specificationsr>   r   r   s        r   make_multiplezScriptMaker.make_multiple  sE     	+ 	@ 	@MTYY}g>>????r   )TFN)r   Nr   )"r   
__module____qualname____doc__SCRIPT_TEMPLATEr{   r   r5   rA   r0   r[   r   rK   rS   ra   ru   r   _DEFAULT_MANIFESTr   r   r   r   r   r   r   propertyr3   setterr(   r)   r*   r   r   r    r   r   r   r   G   s         &OJ=A'+- - - -"   |v&& 2
	 
	 
	
	2 
	2 
	2  >C C C CJ> > >
 !H$ $ $8& 8& 8&t 	 	 	I I I I 1 1 1f $ $ X$ ^% % ^% 
w$27f,,T1A1A	" 	" 	"&   &	 	 	 	 	 	r   r   )#ior   loggingr(   rer   r0   r   zipfiler   compatr   r   r   	resourcesr	   utilr
   r   r   r   r   r   	getLoggerr   rH   stripr   compiler   r   r   _enquote_executableobjectr   r   r   r   <module>r      sz          				 				  



        7 7 7 7 7 7 7 7 7 7      : : : : : : : : : : : : : : : : 
	8	$	$  uww! & 
=>>    ) n n n n n& n n n n nr   