
    ;ȋh+                    z   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Zd dl	Z	d dl
mZ d dlmZmZ ddlmZmZ erd dlmZ ddlmZ d d	lmZ d d
lmZ  G d ded          Z G d de          Z G d de          Z G d d          Z G d de          Z G d de          Z d Z!d Z"d Z#d Z$d Z%dS )    )annotationsN)Iterable)TYPE_CHECKING	TypedDict   )metadata	resources)Self)SetuptoolsWarning)first_line_re)get_platformc                  $    e Zd ZU ded<   ded<   dS )
_SplitArgsboolcommentsposixN)__name__
__module____qualname____annotations__     P/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/_scripts.pyr   r      s"         NNNKKKKKr   r   F)totalc                      e Zd ZU dZg Zded<    e            Zed             Z	ed             Z
edd
            Zed             Zedd            ZddZed             Zd Zed             Zed             ZdS )CommandSpeczm
    A command spec for a #! header, specified as a list of arguments akin to
    those passed to Popen.
    z	list[str]optionsc                    | S )zV
        Choose the best CommandSpec class based on environmental conditions.
        r   clss    r   bestzCommandSpec.best'   s	    
 
r   c                    t           j                            t          j                  }t           j                            d|          S )N__PYVENV_LAUNCHER__)ospathnormpathsys
executableenvironget)r    _defaults     r   _sys_executablezCommandSpec._sys_executable.   s0    7##CN33z~~3X>>>r   param!Self | str | Iterable[str] | Nonereturnr
   c                $   t          ||           r|S t          |t                    r|                     |          S t          |t                    r | |          S ||                                 S t          dt          |                     )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)r    r-   s     r   
from_paramzCommandSpec.from_param3   s     eS!! 	LeS!! 	*??5)))eX&& 	3u::='')))IDKKIIJJJr   c                >     | |                                  g          S N)r,   r   s    r   r4   zCommandSpec.from_environmentC   s!    sC''))*+++r   stringr2   c                F    t          j        |fi | j        } | |          S )z}
        Construct a command spec from a simple string representing a command
        line parseable by shlex.split.
        )shlexsplit
split_args)r    r:   itemss      r   r3   zCommandSpec.from_stringG   s+     F55cn55s5zzr   script_textc                    t          j        |                     |                    | _        t	          j        |           }t          |          sdg| j        d d<   d S d S )Nz-xr   )r<   r=   _extract_optionsr   
subprocesslist2cmdlineisascii)selfr@   cmdlines      r   install_optionszCommandSpec.install_optionsP   sc    {4#8#8#E#EFF)$//w 	& $vDL!	& 	&r   c                    | dz                                    d         }t                                          |          }|r|                    d          pdnd}|                                S )zH
        Extract any options from the first line of the script.
        
r   r    )
splitlines_first_line_rematchgroupstrip)orig_scriptfirstrN   r   s       r   rB   zCommandSpec._extract_optionsV   sb    
 t#//11!4  &&u--*/7%++a..&BR}}r   c                V    |                      | t          | j                  z             S r9   )_renderlistr   )rF   s    r   	as_headerzCommandSpec.as_header`   s#    ||D4#5#55666r   c                    d}|D ]8}|                      |          r!|                     |          r| dd         c S 9| S )Nz"'r   )
startswithendswith)item_QUOTESqs      r   _strip_quoteszCommandSpec._strip_quotesc   sW     	" 	"Aq!! "dmmA&6&6 "AbDz!!!r   c                N    t          j        d | D                       }d|z   dz   S )Nc              3  n   K   | ]0}t                               |                                          V  1d S r9   )r   r^   rP   ).0r[   s     r   	<genexpr>z&CommandSpec._render.<locals>.<genexpr>m   sI       *
 *
8<K%%djjll33*
 *
 *
 *
 *
 *
r   z#!rJ   )rC   rD   )r?   rG   s     r   rT   zCommandSpec._renderk   sA    ) *
 *
@E*
 *
 *
 
 
 g~$$r   N)r-   r.   r/   r
   )r:   r2   r/   r
   )r@   r2   )r   r   r   __doc__r   r   r   r>   classmethodr!   r,   r7   r4   r3   rH   staticmethodrB   rV   r^   rT   r   r   r   r   r      sE         
 GJ  [ ? ? [? K K K [K , , [,    [& & & &   \7 7 7   \ % % \% % %r   r   c                  &    e Zd Z ed          ZdS )WindowsCommandSpecF)r   N)r   r   r   r   r>   r   r   r   rg   rg   s   s         %(((JJJr   rg   c                      e Zd ZdZ ej        d                                          ZeZ	e
dd            Zed             Ze
d             Ze
d             Ze
	 	 ddd            ZdS )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              #    K   t          |d          s8t          j        d           t          j                            |j                  }||                                 }|j         d|j	         }dD ]}| d}|j
                            |          D ]^}|j        }|                     |j                   | j        t                      z  }|                     ||j        ||          }	|	E d{V  _dS )z
        Yield write_script() argument tuples for a distribution's
        console_scripts and gui_scripts entry points.
        entry_pointsz%Unsupported distribution encountered.Nz==consolegui_scripts)rO   )hasattrr   emitr   Distributionategg_info
get_headernameversionrk   select_ensure_safe_nametemplatelocals_get_script_args)
r    distheaderspectype_rO   eprv   r@   argss
             r   get_argszScriptWriter.get_args   s      t^,, 	;"#JKKK(++DM::D>^^%%F)--t|--% 	  	 E&&&E'..U.;;    w%%bg...!lVXX5++E27FKPP 	  	 r   c                R    t          j        d|           }|rt          d          dS )z?
        Prevent paths in *_scripts entry point names.
        z[\\/]z+Path separators not allowed in script namesN)research
ValueError)rv   has_path_seps     r   ry   zScriptWriter._ensure_safe_name   s9    
 y400 	LJKKK	L 	Lr   c                    t           j        dk    s t          j        dk    r)t          j        dk    rt
                                          S | S )zD
        Select the best ScriptWriter for this environment.
        win32javant)r'   platformr$   rv   _nameWindowsScriptWriterr!   r   s    r   r!   zScriptWriter.best   s@    
 <7""rw&'8'8RX=M=M&++---Jr   c              #     K   |||z   fV  d S r9   r   )r    r   rv   r~   r@   s        r   r|   zScriptWriter._get_script_args   s$       Vk)******r   rK   r@   r2   r(   (str | CommandSpec | Iterable[str] | Noner/   c                    | j                                                             |          }|                    |           |                                S )z;Create a #! line, getting options (if any) from script_text)command_spec_classr!   r7   rH   rV   )r    r@   r(   cmds       r   ru   zScriptWriter.get_header   sH     $))++66zBBK(((}}r   r9   )rK   N)r@   r2   r(   r   r/   r2   )r   r   r   rc   textwrapdedentlstriprz   r   r   rd   r   re   ry   r!   r|   ru   r   r   r   ri   ri   w   s         
 x!	# #F fhhG J %      [ 0 L L \L   [ + + [+  ?C    [  r   ri   c                  j    e Zd ZeZed             Zed             Zed             Ze	d             Z
dS )r   c                ~    t          t          |           }t          j                            dd          }||         S )zC
        Select the best ScriptWriter suitable for Windows
        )r(   naturalSETUPTOOLS_LAUNCHERr(   )dictWindowsExecutableLauncherWriterr$   r)   r*   )r    writer_lookuplaunchers      r   r!   zWindowsScriptWriter.best   sA    
 6
 
 

 :>>"7FFX&&r   c              #    K   t          dd          |         }|t          j        d                                                             d          vr- dj        di t                      }t          j        |           g d}|	                    |           | 
                    ||          }fd|D             }|z   ||z   d	|fV  d
S )z For Windows, add a .py extension.pya.pywrl   PATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.)r   .py
-script.py.pyc.pyor   .exec                    g | ]}|z   S r   r   ra   xrv   s     r   
<listcomp>z8WindowsScriptWriter._get_script_args.<locals>.<listcomp>       ***D1H***r   tNr   )r   r$   r)   lowerr=   formatr{   r   rq   remove_adjust_header)	r    r   rv   r~   r@   extmsgoldblockerss	     `      r   r|   z$WindowsScriptWriter._get_script_args   s       6v...u5bj+113399#>>>>-! ! xx! !C "3'''KKK

3##E622****c***Sj&;.X======r   c                    d}d}|dk    r||}}t          j        t          j        |          t           j                  }|                    ||          }|                     |          r|n|S )z
        Make sure 'pythonw' is used for gui and 'python' is used for
        console (regardless of what sys.executable is).
        zpythonw.exez
python.exern   )r:   repl)r   compileescape
IGNORECASEsub_use_header)r    r   orig_headerpatternr   
pattern_ob
new_headers          r   r   z"WindowsScriptWriter._adjust_header  sm      E>> 'TGZ	' 2 2BMBB
^^;T^BB
 __Z88IzzkIr   c                    | dd                              d          }t          j        dk    pt          j        |          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.
           rX   "r   )rP   r'   r   shutilwhich)r   clean_headers     r   r   zWindowsScriptWriter._use_header  s<     "!B$'--c22|w&D&,|*D*DDr   N)r   r   r   rg   r   rd   r!   r|   r   re   r   r   r   r   r   r      s        +
' 
' [
' > > [> J J [J 	E 	E \	E 	E 	Er   r   c                  $    e Zd Zed             ZdS )r   c              #    K   |dk    rd}d}dg}nd}d}g d}|                      ||          }fd|D             }	|z   ||z   d|	fV  d	z   t          |          d
fV  t                      sdz   }
|
t                    dfV  dS dS )zG
        For Windows, add a .py extension and an .exe launcher
        rn   z-script.pywr   clir   )r   r   r   c                    g | ]}|z   S r   r   r   s     r   r   zDWindowsExecutableLauncherWriter._get_script_args.<locals>.<listcomp>+  r   r   r   r   bz.exe.manifestN)r   get_win_launcheris_64bitload_launcher_manifest)r    r   rv   r~   r@   launcher_typer   r   hdrr   m_names     `        r   r|   z0WindowsExecutableLauncherWriter._get_script_args  s      
 E>>!MC(CC!MC)))C  //****c***cz3,c8<<<<6M]++
 	
 	
 	

 zz 	> O+F1$77======	> 	>r   N)r   r   r   rd   r|   r   r   r   r   r     s-        > > [> > >r   r   c                F   |  d}t                      r@t                      dk    r|                    dd          }n-|                    dd          }n|                    dd          }t          j        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.
setuptools)r   r   replacer	   filesjoinpath
read_bytes)r6   launcher_fns     r   r   r   <  s     ---Kzz 7>>[((%--c9==KK%--c6::KK!))#v66?<((11+>>IIKKKr   c                    t          j        t                                        d          }|                    d          t                      z  S )Nzlauncher manifest.xmlzutf-8)encoding)r	   r   r   r   	read_textvars)rv   ress     r   r   r   O  s=    
/(
#
#
,
,-D
E
EC=='=**TVV33r   c                     t          t          j        t                    rt          S t	          j        t          j                                                  S )z_
    Return a regular expression based on first_line_re suitable for matching
    strings.
    )r1   r   r   r2   r   r   decoder   r   r   rM   rM   T  s@    
 -'--  :m+2244555r   c                 2    t          j        d          dk    S )NP   )structcalcsizer   r   r   r   r   `  s    ?31$$r   c                V    	 |                      d           n# t          $ r Y dS w xY wdS )NasciiFT)encodeUnicodeError)ss    r   rE   rE   d  sC    	   uu4s    
&&)&
__future__r   r$   r   r<   r   r   rC   r'   r   collections.abcr   typingr   r   
_importlibr   r	   typing_extensionsr
   warningsr   distutils.command.build_scriptsr   distutils.utilr   r   rU   r   rg   ri   r   r   r   r   rM   r   rE   r   r   r   <module>r      sj   " " " " " " 				 				        



  $ $ $ $ $ $ + + + + + + + + + + + + + + + + '&&&&&& ' ' ' ' ' ' 9 9 9 9 9 9 ' ' ' ' ' '    %    
R% R% R% R% R%$ R% R% R%j) ) ) ) ) ) ) )g g g g g g g gT8E 8E 8E 8E 8E, 8E 8E 8Ev> > > > >&9 > > >@L L L&4 4 4
	6 	6 	6% % %    r   