
    F\h!                     4   S SK r S SKrS SKrS SKrS SKrS SKrS SKr/ SQrSr\R                  R                  S5      (       a  SrO\R                  " 5       r " S S\5      r\ R                  S 5       rS	 rSS
 jr  SS jrS rSS jr\S:X  a  \" 5         gg)    N)ZipAppErrorcreate_archiveget_interpreterz8# -*- coding: utf-8 -*-
import {module}
{module}.{fn}()
winutf-8c                       \ rS rSrSrg)r   !    N)__name__
__module____qualname____firstlineno____static_attributes__r
       /usr/lib/python3.13/zipapp.pyr   r   !   s    r   r   c              #      #    [        U [        [        R                  45      (       a  [	        X5       nUv   S S S 5        g U v   g ! , (       d  f       g = f7fN)
isinstancestrosPathLikeopen)archivemodefs      r   _maybe_openr   %   sA     'C-..' AG !   ! s   1AAA
AAc                 l    U(       a-  SUR                  [        5      -   S-   nU R                  U5        gg)zWrite a shebang line.   #!   
N)encodeshebang_encodingwrite)r   interpretershebangs      r   _write_file_prefixr%   .   s1    +,,-=>>F	 r   c                    [        U S5       nUR                  S5      nUS:X  a  SnUR                  5         [        US5       n[        XR5        UR	                  U5        [
        R                  " X55        SSS5        SSS5        U(       a]  [        U[        5      (       aG  [        R                  " U[        R                  " U5      R                  [        R                  -  5        ggg! , (       d  f       N{= f! , (       d  f       N= f)z8Copy an application archive, modifying the shebang line.rb   r   r   wbN)r   readreadliner%   r"   shutilcopyfileobjr   r   r   chmodstatst_modeS_IEXEC)r   new_archiver#   srcfirst_2dsts         r   _copy_archiver6   5   s    	Wd	#s ((1+eGLLNd+ss0 IIgs( , 
$" z+s33
bggk2::T\\IJ 4{ ,+ 
$	#s#   6C<3C+6C<+
C9	5C<<
D
c                 :   Sn[        U S5      (       a  [        U S5      (       a  SnO-[        R                  " U 5      n U R                  5       (       a  SnU(       a  [	        XU5        gU R                  5       (       d  [        S5      eU S-  R                  5       nU(       a  U(       a  [        S5      eU(       d  U(       d  [        S	5      eSnU(       a  UR                  S
5      u  pn[        S U	R                  S5       5       5      n[        S UR                  S5       5       5      nU
S
:X  a  U(       a  U(       d  [        SU-   5      e[        R                  XS9nUc  U R                  S5      nO'[        US5      (       d  [        R                  " U5      n[        U R                  S5      5      nX;   a  [        SU S35      e[        US5       n[!        X5        U(       a  ["        R$                  O["        R&                  n["        R(                  " USUS9 nU HF  nUR+                  U 5      nUb  U" U5      (       d  M&  UR-                  UUR/                  5       5        MH     U(       a!  UR1                  SUR3                  S5      5        SSS5        SSS5        U(       aM  [        US5      (       d;  UR5                  UR7                  5       R8                  [6        R:                  -  5        ggg! , (       d  f       Nk= f! , (       d  f       Nt= f)a*  Create an application archive from SOURCE.

The SOURCE can be the name of a directory, or a filename or a file-like
object referring to an existing archive.

The content of SOURCE is packed into an application archive in TARGET,
which can be a filename or a file-like object.  If SOURCE is a directory,
TARGET can be omitted and will default to the name of SOURCE with .pyz
appended.

The created application archive will have a shebang line specifying
that it should run with INTERPRETER (there will be no shebang line if
INTERPRETER is None), and a __main__.py which runs MAIN (if MAIN is
not specified, an existing __main__.py will be used).  It is an error
to specify MAIN for anything other than a directory source with no
__main__.py, and it is an error to omit MAIN if the directory has no
__main__.py.
Fr*   r+   TNzSource does not existz__main__.pyz8Cannot specify entry point if the source has __main__.pyzArchive has no entry point:c              3   @   #    U  H  oR                  5       v   M     g 7fr   isidentifier.0parts     r   	<genexpr>!create_archive.<locals>.<genexpr>{   s     D^T&&((^   .c              3   @   #    U  H  oR                  5       v   M     g 7fr   r:   r<   s     r   r?   r@   |   s     BMD%%''MrA   zInvalid entry point: )modulefnz.pyzr"   *zThe target archive z$ overwrites one of the source files.r)   w)compressionr   )hasattrpathlibPathis_filer6   existsr   	partitionallsplitMAIN_TEMPLATEformatwith_suffixsortedrglobr   r%   zipfileZIP_DEFLATED
ZIP_STOREDZipFilerelative_tor"   as_posixwritestrr    r.   r/   r0   r1   )sourcetargetr#   mainfilter
compressedsource_is_filehas_mainmain_pymodseprE   mod_okfn_okfiles_to_addfdrH   zchildarcnames                       r   r   r   L   s}   * Nvv76:#>#>f%>>!Nfk2 ==??122&//1HFH 	HH677G~~c*"DSYYs^DDBBHHSMBBs
v%5<==&&c&9~##F+VW%%f%
 &,,s+,L  !&)MNP 	P 
VT	"b2+/9w++)) 	__R+>!%++F3>VG__GGE7#3#3#56 & 

='..*AB ?	 
# 76733V[[]**T\\9: 4{ ?>	 
#	"s,   A	L!%K;
AK;L;
L		L
Lc                     [        U S5       nUR                  S5      S:X  a:  UR                  5       R                  5       R	                  [
        5      sS S S 5        $  S S S 5        g ! , (       d  f       g = f)Nr'   r(   r   )r   r*   r+   stripdecoder!   )r   r   s     r   r   r      sS    	Wd	#q66!9::<%%'../?@ 
$	# 
$	#	#s   AA''
A5c                 b   SSK nUR                  5       nUR                  SSSSS9  UR                  SSSS	S9  UR                  S
SSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSS9  UR                  U 5      n U R                  (       a  [
        R                  R                  U R                  5      (       d  [        S5      e[        U R                  5      n[        SR                  U=(       d    S5      5        [        R                  " S5        [
        R                  R                  U R                  5      (       a  U R                  bg  [
        R                  R!                  U R                  5      (       aD  [
        R                  R#                  U R                  U R                  5      (       a  [        S5      eU R$                  (       a  [        S5      e['        U R                  U R                  U R(                  U R$                  U R*                  S9  g)zRun the zipapp command line interface.

The ARGS parameter lets you specify the argument list directly.
Omitting ARGS (or setting it to None) works as for argparse, using
sys.argv[1:] as the argument list.
r   Nz--outputz-ozAThe name of the output archive. Required if SOURCE is an archive.)defaulthelpz--pythonz-pzEThe name of the Python interpreter to use (default: no shebang line).z--mainz-mzLThe main function of the application (default: use an existing __main__.py).z
--compressz-c
store_truezQCompress files with the deflate method. Files are stored uncompressed by default.)actionrs   z--infoFz)Display the interpreter from the archive.)rr   ru   rs   r]   z'Source directory (or existing archive).)rs   z%Can only get info for an archive filezInterpreter: {}z<none>z-In-place editing of archives is not supportedz,Cannot change the main function when copying)r#   r_   ra   )argparseArgumentParseradd_argument
parse_argsinfor   pathisfiler]   
SystemExitr   printrR   sysexitoutputrM   samefiler_   r   pythoncompress)argsrv   parserr#   s       r   r_   r_      s    $$&F

D$5  6 
D$/  0 $;  < d<=  > %<  >
:  < T"D yyww~~dkk**DEE%dkk2&&{'>h?@	ww~~dkk"";;277>>$++#>#>#%77#3#3DKK#M#MLMM99KLL4;;#{{"mm-r   __main__r   )NNNNF)
contextlibr   rJ   r,   r/   r   rV   __all__rQ   platform
startswithr!   getfilesystemencoding
ValueErrorr   contextmanagerr   r%   r6   r   r   r_   r   r
   r   r   <module>r      s     	    
 
> <<5!!002	* 	  K. @D+0^;BA.-b zF r   