
    .Ph              	       &   U d 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	m
Z
 ddlmZ erddlmZ ed         Zed         Zd	d
gZdddddddddZee
d         ef         ed<   dZdedefdZdededefdZ G d d	e          Z G d d
          ZdS )z2Generate executable scripts, on various platforms.    N)read_binary)TYPE_CHECKINGMappingOptionalTuple)_scripts)Literal)posixwin-ia32	win-amd64win-arm	win-arm64)consoleguiInvalidScriptScriptzt32.exezt64.exez	t_arm.exezt64-arm.exezw32.exezw64.exez	w_arm.exezw64-arm.exe))r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )ScriptSectionLauncherKind_ALLOWED_LAUNCHERSz# -*- coding: utf-8 -*-
import re
import sys
from {module} import {import_name}
if __name__ == "__main__":
    sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
    sys.exit({func_path}())

executablereturnc                 >    d| v rdS t          |           dz   }|dk    S )N    F      )len)r   shebang_lengths     Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/installer/scripts.py_is_executable_simpler   +   s/    zu__q(N S      forlauncherc                     |                      d          }|rd|z   S t          |          rd|z   S t          j        |                                d          }d|z   dz   dz   S )a  Build a shebang line.

    The non-launcher cases are taken directly from distlib's implementation,
    which tries its best to account for command length, spaces in path, etc.

    https://bitbucket.org/pypa/distlib/src/58cd5c6/distlib/scripts.py#lines-124
    utf-8s   #!s   #!/bin/sh
'''exec' s    "$0" "$@"
s   ' ''')encoder   shlexquote)r   r!   executable_bytesquoteds       r   _build_shebangr)   5   s}     "((11 ('''-.. (''' [$$++G44F"V+o=HHr    c                       e Zd ZdZdS )r   z=Raised if the user provides incorrect script section or kind.N)__name__
__module____qualname____doc__ r    r   r   r   N   s        GGGGr    c            
       ~    e Zd ZdZdZdedededddd	f
d
ZdefdZdddee	         fdZ
dedddeee	f         fdZd	S )r   z7Describes a script based on an entry point declaration.namemoduleattrsectionr2   r3   r4   r5   r   r   Nc                 >    || _         || _        || _        || _        dS )ax  Construct a Script object.

        :param name: name of the script
        :param module: module path, to load the entry point from
        :param attr: final attribute access, for the entry point
        :param section: Denotes the "entry point section" where this was specified.
            Valid values are ``"gui"`` and ``"console"``.
        :type section: str

        Nr1   )selfr2   r3   r4   r5   s        r   __init__zScript.__init__W   s$     		r    c                 N    d                     | j        | j        | j                  S )Nz(Script(name={!r}, module={!r}, attr={!r})formatr2   r3   r4   )r7   s    r   __repr__zScript.__repr__i   s)    9@@IKI
 
 	
r    kindr   c                     |dk    rd S | j         |f}	 t          |         }n6# t          $ r) |dt          t                    }t	          |          w xY wt          t          |          S )Nr
   z not in )r5   r   KeyErrorsortedr   r   r   )r7   r<   keyr2   errors        r   _get_launcher_datazScript._get_launcher_datap   s    7??4|T"	'%c*DD 	' 	' 	'DDf-?&@&@DDE&&&	' 8T***s	   ! 3Ar   c                 <   |                      |          }t          |t          |                    }t                              | j        | j                            d          d         | j                                      d          }|| j	        |dz   |z   fS t          j                    }t          j        |d          5 }|                    d	|           ddd           n# 1 swxY w Y   | j	         d
}||z   dz   |                                z   }	||	fS )a  Generate a launcher for this script.

        :param executable: Path to the executable to invoke.
        :param kind: Which launcher template should be used.
            Valid values are ``"posix"``, ``"win-ia32"``, ``"win-amd64"`` and
            ``"win-arm"``.
        :type kind: str

        :raises InvalidScript: if no appropriate template is available.
        :return: The name and contents of the launcher file.
        )r!   .r   )r3   import_name	func_pathr#   N   
wz__main__.pyz.exe)rB   r)   bool_SCRIPT_TEMPLATEr:   r3   r4   splitr$   r2   ioBytesIOzipfileZipFilewritestrgetvalue)
r7   r   r<   launchershebangcodestreamzfr2   datas
             r   generatezScript.generate{   sR    **400 hHHH&&;	,,Q/i ' 
 
 &//	 	 Iw566_VS)) 	-RKKt,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-)!!!'!E)FOO,=,==d|s   C((C,/C,)r+   r,   r-   r.   	__slots__strr8   r;   r   bytesrB   r   rX   r/   r    r   r   r   R   s        AA5I!$,/:I	   $
# 
 
 
 
	+~ 	+(5/ 	+ 	+ 	+ 	+3 n sEzAR      r    )r.   rL   r%   rN   importlib.resourcesr   typingr   r   r   r   	installerr   r	   r   r   __all__r   rZ   __annotations__rJ   r[   rI   r   r)   
ValueErrorr   r   r/   r    r   <module>rb      s   8 8 8 				   + + + + + + : : : : : : : : : : : :       .STL,-M H
% '''+"##'	L 	L GE"ABCGH 	 	 	 !e ! ! ! ! !Is I I% I I I I2H H H H HJ H H HE E E E E E E E E Er    