
    k"gG                        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j5                         Z ej8                  d	      Zd
Zd ZeZ  G d de!      Z"y)    )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 r[| j                  d      r4| j                  dd      \  }}d|v r|j                  d      s|d|d} | S | j                  d      sd| z  } | S )N z/usr/bin/env r   "z "z"%s")
startswithsplit)
executableenv_executables      T/var/www/html/djangosite/lib/python3.12/site-packages/pip/_vendor/distlib/scripts.pyenquote_executabler   5   sx    
j
   1)//Q7Ck!+*@*@*E*-{;
  ((-#j0
    c                   N   e Zd ZdZeZdZ	 	 	 ddZd Ze	j                  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j6                  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!y)ScriptMakerz_
    A class to copy or create scripts from source scripts or callable
    specifications.
    Nc                    || _         || _        || _        d| _        d| _        t
        j                  dk(  xs( t
        j                  dk(  xr t
        j                  dk(  | _        t        d      | _
        |xs t        |      | _        t
        j                  dk(  xs( t
        j                  dk(  xr t
        j                  dk(  | _        t        j                  | _        y )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__R   s     %$*
G+ JF1B 2I57XX5H 	K(6g!6ggo @"''V*; +?.0hh$.> 	,,r   c                     |j                  dd      r`| j                  rTt        j                  j	                  |      \  }}|j                  dd      }t        j                  j                  ||      }|S )NguiFpythonpythonw)getr/   r(   pathr   replacejoin)r2   r   optionsdnfns        r   _get_alternate_executablez%ScriptMaker._get_alternate_executableg   sV    ;;ue$WW]]:.FBHi0Bb"-Jr   r   c                     	 t        |      5 }|j                  d      dk(  cddd       S # 1 sw Y   yxY w# t        t        f$ r t        j                  d|       Y y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_shellp   s[    
*% .771:-. . .W% 2J?s#   7 +	7 47 7 %AAc                     | j                  |      r3dd l}|j                  j                  j	                  d      dk(  r|S d|z  S |j                         j                  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_executable|   sk    ~~j)99##//	:gE%% %z11 !!#,,\:!!$z11r   c                     t         j                  dk7  rd}n=t        |      t        |      z   dz   }t        j                  dk(  rd}nd}d|vxr ||k  }|rd|z   |z   d	z   }|S 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     77g!N !_s;/??!CN||x'%("%("#:5 I#15G#G  Z'+5=F
  $FlZ/+=OOFhFr   c                    d}| j                   r| j                   }d}n/t        j                         st               }nt	               rJt
        j                  j                  t        j                  d      dt        j                  d      z        }nt
        j                  dk(  rJt
        j                  j                  t        j                  d      dt        j                  d      z        }n^t
        j                  j                  t        j                  d      dt        j                  d	      t        j                  d            }|r| j                  ||      }t        j                  j                  d
      r| j                  |      }|rt!        |      }|j#                  d      }t        j                  dk(  rd|vr	d|vr|dz  }| j%                  ||      }	 |j'                  d       |dk7  r	 |j'                  |       |S |S # t(        $ r t+        d|z        w xY w# t(        $ r t+        d|d|d      w xY w)NTFscriptszpython%sEXEr"   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_varr)   rA   r0   r[   r   rS   r   encodera   decodeUnicodeDecodeError
ValueError)r2   encodingr\   r>   enquoter   shebangs          r   _get_shebangzScriptMaker._get_shebang   s   ??JG**,')JY""9-Y55e<<>J ww$  WW\\,,X6)":":5"ABD
  WW\\,,X6$-$<$<Y$G$-$<$<U$CEF
 77
GLJ<<""6*44Z@J +J7J  &&w/
LLE!k&D#;6=(K%%j+>	&NN7# w6x(
 w " 	&K$% & &	& & 6 ")8"5 6 66s   #H :H* H'*Ic                     | j                   t        |j                  |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   sA    ##d<<**3/2'  	r   c                 ^    t         j                  j                  |      }| j                  |z  S N)r(   r;   basenamemanifest)r2   exenamebases      r   get_manifestzScriptMaker.get_manifest   s%    ww(}}t##r   c                    | j                   xr | j                  }t        j                  j	                  d      }|j                  |      s||z  }|s||z   }n|dk(  r| j                  d      }n| j                  d      }t               }	t        |	d      5 }
t        j                  j                  d      }|rAt        j                  t        |            d d }t        d|      }|
j                  ||       n|
j                  d|       d d d        |	j!                         }||z   |z   }|D ]E  }t        j"                  j%                  | j&                  |      }|rXt        j"                  j)                  |      \  }}|j+                  d	      r|}d
|z  }	 | j,                  j/                  ||       n| j                  r|j                  d|z         s|d|}t        j"                  j7                  |      r#| j>                  st2        j5                  d|       | j,                  j/                  ||       | j@                  r| j,                  jC                  |g       |jE                  |       H y # 1 sw Y   nxY w# t0        $ r t2        j5                  d       d|z  }t        j"                  j7                  |      rt        j8                  |       t        j:                  ||       | j,                  j/                  ||       t2        j=                  d       	 t        j8                  |       n# t0        $ r Y nw xY wY w xY w)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 logicrv   zSkipping existing file %s)#r%   r/   r(   lineseprm   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   namesrs   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   ))9dkk**##G,(wG"\1Ld{--c2--c2YF% =$&JJNN3F$G!$ $C0A,B CBQ GI#].79EKK|4KK|<= (H#g-8L "	&Dggll4??D9Gww''01<<&G"W,LL227LI" ;;w'7'7c	(#)0#6G77>>'*4<<NN#>H..wE==LL44gY?W%E"	&= =( ! NN $9 :*W4Fww~~f-		&)IIgv.LL227LILL "3 4		&)$ sD   A5I7J7JBM#L98M9	MMMM
M-c                 P   t               }d| j                  v r|j                  |       d| j                  v r"|j                  || j                  d          d| j                  v r>|j                  || j                  | j                  d   d| j                  d          |S )Nr    Xr   r!   rv   r   )r,   r-   addr1   variant_separator)r2   r)   r`   s      r   get_script_filenamesz ScriptMaker.get_script_filenames9  s    JJt$--JJt'8'8';<=DMM!JJd44d6G6G6J))!,. / r   c                 x   d}|r9|j                  dg       }|r%ddj                  |      z  }|j                  d      }| j                  d||      }| j	                  |      j                  d      }| j                  |j                        }|r|j                  dd      rd	}	nd
}	| j                  |||||	       y )Nr   interpreter_argsz %sr   rg   r>   r7   Fpywr   )r:   r=   rm   rt   r   r   r)   r   )
r2   r~   r   r>   r\   argsrs   scriptscriptnamesr   s
             r   _make_scriptzScriptMaker._make_scriptE  s    ;;126Dsxx~-"kk'2##G['#J&&u-44W=//

;w{{5%0CC;CHr   c                    d}t         j                  j                  | j                  t	        |            }t         j                  j                  | j
                  t         j                  j                  |            }| j                  s3| j                  j                  ||      st        j                  d|       y 	 t        |d      }|j                         }|st        j                  d|       y t        j!                  |j#                  dd            }|rd}|j%                  d      xs d	}	 |sh|r|j+                          | j                  j-                  ||       | j.                  r| j                  j1                  |g       |j3                  |       y t        j5                  d
|| j
                         | j                  j(                  st7        |j                        \  }	}
|j9                  d       | j;                  |	      }dv rd}nd}t         j                  j                  |      }| j=                  |g||j?                         ||       |r|j+                          y y # t&        $ r | j(                  s d }Y Ww xY w)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   seekrt   r   rE   )r2   r   r   adjustr   f
first_liner   r\   rq   linesrs   r   r   s                 r   _copy_scriptzScriptMaker._copy_scriptU  s   doo|F/CD'',,t0@0@0HIzz$,,"4"4VW"ELL6?
	4VT"A J?H!''
(:(:7E(JKE#kk!n3	LL""673}}00';W%KK8&)<<''"1!**"=%q	++HkB+CCGG$$W-""A39cJ	 G  	<<A	s   =I- -J	J	c                 .    | j                   j                  S r   r.   r3   )r2   s    r   r3   zScriptMaker.dry_run  s    ||###r   c                 &    || j                   _        y 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        j	                  d	d
      d   }t        |      j                  |      }|sd|d|}t        |      |j                  S )NP   6432z	win-arm64z-armr    z.exerv   r   r   zUnable to find resource z in package )	structcalcsizer   __name__rsplitr	   findrp   bytes)r2   kindbitsplatform_suffixr)   distlib_packageresourcemsgs           r   r   zScriptMaker._get_launcher  s    s#q((4+(Ef2O#'?D 'ooc15a8Oo.33D9Ho/ o%>>!r   c                 t    g }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   r   r   )r2   specificationr>   r   r~   s        r   makezScriptMaker.make  sM     	 /=mY7  eY@r   c                 Z    g }|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   )r2   specificationsr>   r   r   s        r   make_multiplezScriptMaker.make_multiple  s9     	+ 	@MTYY}g>?	@r   )TFN)r   Nr   )"r   
__module____qualname____doc__SCRIPT_TEMPLATErz   r   r5   rA   r0   r[   r   rK   rS   ra   rt   r   _DEFAULT_MANIFESTr   r   r   r   r   r   r   propertyr3   setterr(   r)   r*   r   r   r    r   r   r   r   I   s     &OJ
  $-* ||v&
	
	2>FP !H$:&x 
I 1f $ $ ^^% % 
ww$277f,!xx4/	"&&	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      s      	 	  
   7 7 : : 
		8	$  uw! & 

=>" ) {& {r   