HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/setuptools/__pycache__/_scripts.cpython-310.pyc
o

;j�+�@s:ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddlmZmZe
rDddlmZddlmZdd	lmZdd
lmZGdd�ded
d�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�Z dd�Z!dd�Z"dd�Z#dd �Z$d!d"�Z%dS)#�)�annotationsN)�Iterable)�
TYPE_CHECKING�	TypedDict�)�metadata�	resources)�Self)�SetuptoolsWarning)�
first_line_re)�get_platformc@seZdZUded<ded<dS)�
_SplitArgs�boolZcomments�posixN)�__name__�
__module__�__qualname__�__annotations__�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/setuptools/_scripts.pyr
s
r
F)�totalc@s�eZdZUdZgZded<e�Zedd��Z	edd��Z
ed dd
��Zedd��Zed!dd��Z
d"dd�Zedd��Zdd�Zedd��Zedd��ZdS)#�CommandSpeczm
    A command spec for a #! header, specified as a list of arguments akin to
    those passed to Popen.
    z	list[str]�optionscCs|S)zV
        Choose the best CommandSpec class based on environmental conditions.
        r��clsrrr�best'szCommandSpec.bestcCstj�tj�}tj�d|�S)N�__PYVENV_LAUNCHER__)�os�path�normpath�sys�
executable�environ�get)r�_defaultrrr�_sys_executable.szCommandSpec._sys_executable�param�!Self | str | Iterable[str] | None�returnr	cCsVt||�r|St|t�r|�|�St|t�r||�S|dur"|��Stdt|�����)zg
        Construct a CommandSpec from a parameter to build_scripts, which may
        be None.
        Nz!Argument has an unsupported type )�
isinstance�str�from_stringr�from_environment�	TypeError�type)rr&rrr�
from_param3s



zCommandSpec.from_paramcCs||��g�S�N)r%rrrrr,CszCommandSpec.from_environment�stringr*cCstj|fi|j��}||�S)z}
        Construct a command spec from a simple string representing a command
        line parseable by shlex.split.
        )�shlex�split�
split_args)rr1�itemsrrrr+GszCommandSpec.from_string�script_textcCs<t�|�|��|_t�|�}t|�sdg|jdd�<dSdS)Nz-xr)r2r3�_extract_optionsr�
subprocess�list2cmdline�isascii)�selfr6�cmdlinerrr�install_optionsPs

�zCommandSpec.install_optionscCs:|d��d}t��|�}|r|�d�pdnd}|��S)zH
        Extract any options from the first line of the script.
        �
rr�)�
splitlines�_first_line_re�match�group�strip)Zorig_script�firstrBrrrrr7Vs�zCommandSpec._extract_optionscCs|�|t|j��Sr0)�_render�listr)r;rrr�	as_header`szCommandSpec.as_headercCs6d}|D]}|�|�r|�|�r|dd�Sq|S)Nz"'r���)�
startswith�endswith)�itemZ_QUOTES�qrrr�
_strip_quotescs�zCommandSpec._strip_quotescCs t�dd�|D��}d|dS)Ncss�|]
}t�|���VqdSr0)rrNrD)�.0rLrrr�	<genexpr>ms�
�z&CommandSpec._render.<locals>.<genexpr>z#!r>)r8r9)r5r<rrrrFks
�zCommandSpec._renderN)r&r'r(r	)r1r*r(r	)r6r*)rrr�__doc__rrr
r4�classmethodrr%r/r,r+r=�staticmethodr7rHrNrFrrrrrs,





	
rc@seZdZedd�ZdS)�WindowsCommandSpecF)rN)rrrr
r4rrrrrTssrTc@sheZdZdZe�d���ZeZ	e
ddd��Zedd��Z
e
dd	��Ze
d
d��Ze
		dddd��ZdS)�ScriptWriterz`
    Encapsulates behavior around writing entry point scripts for console and
    gui apps.
    aJ
        # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
        import re
        import sys

        # for compatibility with easy_install; see #2198
        __requires__ = %(spec)r

        try:
            from importlib.metadata import distribution
        except ImportError:
            try:
                from importlib_metadata import distribution
            except ImportError:
                from pkg_resources import load_entry_point


        def importlib_load_entry_point(spec, group, name):
            dist_name, _, _ = spec.partition('==')
            matches = (
                entry_point
                for entry_point in distribution(dist_name).entry_points
                if entry_point.group == group and entry_point.name == name
            )
            return next(matches).load()


        globals().setdefault('load_entry_point', importlib_load_entry_point)


        if __name__ == '__main__':
            sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
            sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())
        Nc
cs��t|d�st�d�tj�|j�}|dur|��}|j�d|j	��}dD].}|�d�}|j
j|d�D]}|j}|�|j�|j
t�}|�||j||�}	|	EdHq3q%dS)z�
        Yield write_script() argument tuples for a distribution's
        console_scripts and gui_scripts entry points.
        �entry_pointsz%Unsupported distribution encountered.Nz==�Zconsole�guiZ_scripts)rC)�hasattrr
�emitrZDistributionZatZegg_info�
get_header�name�versionrV�select�_ensure_safe_name�template�locals�_get_script_args)
r�dist�header�spec�type_rCZepr\r6�argsrrr�get_args�s"�
	

��zScriptWriter.get_argscCst�d|�}|rtd��dS)z?
        Prevent paths in *_scripts entry point names.
        z[\\/]z+Path separators not allowed in script namesN)�re�search�
ValueError)r\Zhas_path_seprrrr_�s�zScriptWriter._ensure_safe_namecCs*tjdkstjdkrtjdkrt��S|S)zD
        Select the best ScriptWriter for this environment.
        �win32�java�nt)r �platformrr\�_name�WindowsScriptWriterrrrrrr�szScriptWriter.bestccs�|||fVdSr0r)rrfr\rdr6rrrrb�s�zScriptWriter._get_script_argsr?r6r*r!�(str | CommandSpec | Iterable[str] | Noner(cCs"|j���|�}|�|�|��S)z;Create a #! line, getting options (if any) from script_text)�command_spec_classrr/r=rH)rr6r!�cmdrrrr[�s
zScriptWriter.get_headerr0)r?N)r6r*r!rrr(r*)rrrrQ�textwrap�dedent�lstripr`rrsrRrhrSr_rrbr[rrrrrUws(�#�%

	
�rUc@s@eZdZeZedd��Zedd��Zedd��Ze	dd��Z
d	S)
rqcCs"tt|d�}tj�dd�}||S)zC
        Select the best ScriptWriter suitable for Windows
        )r!ZnaturalZSETUPTOOLS_LAUNCHERr!)�dict�WindowsExecutableLauncherWriterrr"r#)rZ
writer_lookupZlauncherrrrr�s�zWindowsScriptWriter.bestc	#s��tddd�|}|tjd���d�vr#djdit���}t�|�gd�}|�	|�|�
||�}�fdd	�|D�}�|||d
|fVdS)
z For Windows, add a .py extension�.pya�.pywrW�PATHEXT�;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.)rz�.py�
-script.py�.pyc�.pyor{�.exec�g|]}�|�qSrr�rO�x�r\rr�
<listcomp>��z8WindowsScriptWriter._get_script_args.<locals>.<listcomp>�tNr)rxrr"�lowerr3�formatrar
rZ�remove�_adjust_header)	rrfr\rdr6�ext�msg�old�blockersrr�rrb�s���

z$WindowsScriptWriter._get_script_argscCsNd}d}|dkr
||}}t�t�|�tj�}|j||d�}|�|�r%|S|S)z�
        Make sure 'pythonw' is used for gui and 'python' is used for
        console (regardless of what sys.executable is).
        zpythonw.exez
python.exerX)r1�repl)ri�compile�escape�
IGNORECASE�sub�_use_header)rrfZorig_header�patternr�Z
pattern_ob�
new_headerrrrr�s
z"WindowsScriptWriter._adjust_headercCs&|dd��d�}tjdkpt�|�S)z�
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        �rI�"rl)rDr ro�shutil�which)r�Zclean_headerrrrr�s	zWindowsScriptWriter._use_headerN)rrrrTrsrRrrbr�rSr�rrrrrq�s



rqc@seZdZedd��ZdS)ryc#s��|dkr
d}d}dg}nd}d}gd�}|�||�}�fdd�|D�}	�|||d	|	fV�d
t|�dfVt�sJ�d}
|
t��d	fVd
Sd
S)zG
        For Windows, add a .py extension and an .exe launcher
        rXz-script.pywr{Zclir)r~r�r�cr�rrr�r�rrr�+r�zDWindowsExecutableLauncherWriter._get_script_args.<locals>.<listcomp>r�r��bz
.exe.manifestN)r��get_win_launcher�is_64bit�load_launcher_manifest)rrfr\rdr6Z
launcher_typer�r��hdrr�Zm_namerr�rrbs&���z0WindowsExecutableLauncherWriter._get_script_argsN)rrrrRrbrrrrrysrycCsV|�d�}t�rt�dkr|�dd�}n
|�dd�}n|�dd�}t�d��|���S)z�
    Load the Windows launcher (executable) suitable for launching a script.

    `type` should be either 'cli' or 'gui'

    Returns the executable as a byte string.
    r�z	win-arm64�.z-arm64.z-64.z-32.Z
setuptools)r�r�replacer�files�joinpath�
read_bytes)r.Zlauncher_fnrrrr�<s

r�cCs"t�t��d�}|jdd�t�S)Nzlauncher manifest.xmlzutf-8)�encoding)rr�rr��	read_text�vars)r\�resrrrr�Osr�cCs ttjt�rtSt�tj���S)z_
    Return a regular expression based on first_line_re suitable for matching
    strings.
    )r)rr�r*rir��decoderrrrrATsrAcCst�d�dkS)N�P�)�struct�calcsizerrrrr�`sr�cCs&z|�d�WdStyYdSw)N�asciiFT)�encode�UnicodeError)�srrrr:ds��r:)&�
__future__rrrir2r�r�r8r ru�collections.abcr�typingrr�
_importlibrrZtyping_extensionsr	�warningsr
Zdistutils.command.build_scriptsrZdistutils.utilrr
rGrrTrUrqryr�r�rAr�r:rrrr�<module>s8Uj;