
    ,hf*                    L   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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#y)    )annotationsN)Iterable)TYPE_CHECKING	TypedDict)Self   )SetuptoolsWarning)first_line_re)get_platformc                  "    e Zd ZU ded<   ded<   y)
_SplitArgsboolcommentsposixN)__name__
__module____qualname____annotations__     U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/_scripts.pyr   r      s    NKr   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y)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                  j                  t        j                        }t         j
                  j                  d|      S )N__PYVENV_LAUNCHER__)ospathnormpathsys
executableenvironget)r   _defaults     r   _sys_executablezCommandSpec._sys_executable.   s0    77##CNN3zz~~3X>>r   c                    t        ||       r|S t        |t              r| j                  |      S t        |t              r | |      S || j	                         S t        dt        |             )zg
        Construct a CommandSpec from a parameter to build_scripts, which may
        be None.
        z!Argument has an unsupported type )
isinstancestrfrom_stringr   from_environment	TypeErrortype)r   params     r   
from_paramzCommandSpec.from_param3   sk     eS!LeS!??5))eX&u:=''));DK=IJJr   c                0     | | j                         g      S N)r*   r   s    r   r/   zCommandSpec.from_environmentC   s    C'')*++r   c                R    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   stringitemss      r   r.   zCommandSpec.from_stringG   s%     F5cnn55zr   c                    t        j                  | j                  |            | _        t	        j
                  |       }t        |      sdg| j                  d d y y )Nz-xr   )r7   r8   _extract_optionsr   
subprocesslist2cmdlineisascii)selfscript_textcmdlines      r   install_optionszCommandSpec.install_optionsP   sL    {{4#8#8#EF))$/w $vDLL!  r   c                    | dz   j                         d   }t               j                  |      }|r|j                  d      xs dnd}|j	                         S )zH
        Extract any options from the first line of the script.
        
r   r    )
splitlines_first_line_rematchgroupstrip)orig_scriptfirstrJ   r   s       r   r=   zCommandSpec._extract_optionsV   sQ    
 t#//1!4 &&u-*/%++a.&BR}}r   c                P    | j                  | t        | j                        z         S r5   )_renderlistr   )rA   s    r   	as_headerzCommandSpec.as_header`   s    ||D4#5566r   c                l    d}|D ],  }| j                  |      s| j                  |      s'| dd c S  | S )Nz"'r   )
startswithendswith)item_QUOTESqs      r   _strip_quoteszCommandSpec._strip_quotesc   s@     	"Aq!dmmA&6Abz!	" r   c                J    t        j                  d | D              }d|z   dz   S )Nc              3  b   K   | ]'  }t         j                  |j                                ) y wr5   )r   rZ   rL   ).0rW   s     r   	<genexpr>z&CommandSpec._render.<locals>.<genexpr>m   s&      *
8<K%%djjl3*
s   -/z#!rF   )r>   r?   )r;   rC   s     r   rP   zCommandSpec._renderk   s0    )) *
@E*
 
 g~$$r   N)r2   z!Self | str | Iterable[str] | Nonereturnr   )r:   r-   r_   r   )rB   r-   )r   r   r   __doc__r   r   r   r9   classmethodr   r*   r3   r/   r.   rD   staticmethodr=   rR   rZ   rP   r   r   r   r   r      s    
 GYJ  ? ? K K , ,  &  7   % %r   r   c                      e Zd Z ed      Zy)WindowsCommandSpecF)r   N)r   r   r   r   r9   r   r   r   rd   rd   s   s    %(Jr   rd   c                      e Zd ZdZ ej
                  d      j                         ZeZ	e
d	d       Zed        Ze
d        Ze
d        Ze
	 	 d
	 	 	 	 	 dd       Zy)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              #  R  K   || j                         }t        |j                               }dD ]q  }|dz   }|j                  |      j	                         D ]H  }| j                  |       | j                  t               z  }| j                  ||||      }|E d{    J s y7 	w)z
        Yield write_script() argument tuples for a distribution's
        console_scripts and gui_scripts entry points.
        Nconsolegui_scripts)	
get_headerr-   as_requirementget_entry_mapkeys_ensure_safe_nametemplatelocals_get_script_args)	r   distheaderspectype_rK   namerB   argss	            r   get_argszScriptWriter.get_args   s      >^^%F4&&()% 	 EJ&E**51668  %%d+!llVX5++E4M	 	   s   BB'B%
B'c                J    t        j                  d|       }|rt        d      y)z?
        Prevent paths in *_scripts entry point names.
        z[\\/]z+Path separators not allowed in script namesN)research
ValueError)rx   has_path_seps     r   rp   zScriptWriter._ensure_safe_name   s(    
 yy40JKK r   c                    t         j                  dk(  s&t        j                  dk(  r't        j                  dk(  rt
        j                         S | S )zD
        Select the best ScriptWriter for this environment.
        win32javant)r%   platformr"   rx   _nameWindowsScriptWriterr   r   s    r   r   zScriptWriter.best   s:    
 <<7"rww&'8RXX=M&++--Jr   c              #     K   |||z   f y wr5   r   )r   rw   rx   ru   rB   s        r   rs   zScriptWriter._get_script_args   s      Vk)**s   c                    | j                   j                         j                  |      }|j                  |       |j	                         S )z;Create a #! line, getting options (if any) from script_text)command_spec_classr   r3   rD   rR   )r   rB   r&   cmds       r   rl   zScriptWriter.get_header   s=     $$))+66zBK(}}r   r5   )rG   N)rB   r-   r&   z(str | CommandSpec | Iterable[str] | Noner_   r-   )r   r   r   r`   textwrapdedentlstriprq   r   r   ra   rz   rb   rp   r   rs   rl   r   r   r   rf   rf   w   s    
 x!	#F fhG J %     L L   + +  ?C = 
	 r   rf   c                  P    e Zd ZeZed        Zed        Zed        Ze	d        Z
y)r   c                n    t        t        |       }t        j                  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   s6    
 6

 ::>>"7FX&&r   c              #    K   t        dd      |   }|t        j                  d   j                         j	                  d      vr/ dj
                  d
i t               }t        j                  |       g d}|j                  |       | j                  ||      }|D cg c]  }||z   	 }	}||z   ||z   d|	f y	c c}w w)z For Windows, add a .py extension.pya.pywrh   PATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.)r   .py
-script.py.pyc.pyor   .exetNr   )r   r"   r'   lowerr8   formatrr   r	   emitremove_adjust_header)
r   rw   rx   ru   rB   extmsgoldxblockerss
             r   rs   z$WindowsScriptWriter._get_script_args   s      6v.u5bjj+11399#>>-f! x!C ""3'K

3##E62&)*D1H**Sj&;.X== +s   BCB<+Cc                    d}d}|dk(  r||}}t        j                  t        j                  |      t         j                        }|j	                  ||      }| j                  |      r|S |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.exerj   )r:   repl)r|   compileescape
IGNORECASEsub_use_header)r   rw   orig_headerpatternr   
pattern_ob
new_headers          r   r   z"WindowsScriptWriter._adjust_header   sc      E> 'TGZZ		' 2BMMB
^^;T^B
 __Z8zIkIr   c                ~    | dd j                  d      }t        j                  dk7  xs 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.
           rT   "r   )rL   r%   r   shutilwhich)r   clean_headers     r   r   zWindowsScriptWriter._use_header  s8     "!B'--c2||w&D&,,|*DDr   N)r   r   r   rd   r   ra   r   rs   r   rb   r   r   r   r   r   r      sZ    +
' 
' > > J J 	E 	Er   r   c                      e Zd Zed        Zy)r   c              #  
  K   |dk(  rd}d}dg}nd}d}g d}| j                  ||      }|D 	cg c]  }	||	z   	 }
}	||z   ||z   d|
f |dz   t        |      d	f t               s|d
z   }|t        |      df yyc c}	w w)zG
        For Windows, add a .py extension and an .exe launcher
        rj   z-script.pywr   clir   )r   r   r   r   r   bz.exe.manifestN)r   get_win_launcheris_64bitload_launcher_manifest)r   rw   rx   ru   rB   launcher_typer   r   hdrr   r   m_names               r   rs   z0WindowsExecutableLauncherWriter._get_script_args  s     
 E>!MC(C!MC)C  /&)*D1H**cz3,c8<<6M]+
 	

 z O+F1$7==  +s   ,BA>A	BN)r   r   r   ra   rs   r   r   r   r   r     s    > >r   r   c                    |  d}t               r3t               dk(  r|j                  dd      }n%|j                  dd      }n|j                  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   replacepkg_resourcesresource_string)r1   launcher_fns     r   r   r   4  sg     F$-Kz>[(%--c9=K%--c6:K!))#v6(({CCr   c                n    t        j                  t        d      }|j                  d      t	               z  S )Nzlauncher manifest.xmlzutf-8)r   r   r   decodevars)rx   manifests     r   r   r   G  s+    ,,X7NOH??7#df,,r   c                     t        t        j                  t              rt        S t	        j
                  t        j                  j                               S )z_
    Return a regular expression based on first_line_re suitable for matching
    strings.
    )r,   r
   r   r-   r|   r   r   r   r   r   rI   rI   L  s:    
 -''- ::m++22455r   c                 2    t        j                  d      dk(  S )NP   )structcalcsizer   r   r   r   r   X  s    ??31$$r   c                F    	 | j                  d       y# t        $ r Y yw xY w)NasciiFT)encodeUnicodeError)ss    r   r@   r@   \  s,    	   s    	  )$
__future__r   r"   r|   r7   r   r   r>   r%   r   collections.abcr   typingr   r   r   typing_extensionsr   warningsr	   distutils.command.build_scriptsr
   distutils.utilr   r   rQ   r   rd   rf   r   r   r   r   rI   r   r@   r   r   r   <module>r      s    " 	 	     
  $ + & ' 9 '% 
R%$ R%j) )_ _D8E, 8Ev>&9 >@D&-
	6%r   