
    vKg>                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKJ	r	J
r
Jr  SSKJr  SSKJr  SSKJrJr  SSKJr  SS	KJr  SS
KJrJr  SSKJrJrJrJr  SSKJrJ r!  SSK"J#r#  SSK$J%r%  SSK&J'r'  \(       a  SSK(J)r)  SSK*J+r+  \" S5      r,\" SSS9r- " S S5      r. S/     S0S jjr/ S/     S1S jjr0S2S jr1S3S jr2S4S jr3  S5       S6S jjr4S7S jr5S8S  jr6        S9S! jr7  S5       S:S" jjr8  S5       S;S# jjr9SSSS$.     S<S% jjr:S=S& jr;S>S' jr<S?S( jr= S/     S@S) jjr> SA     SBS* jjr? " S+ S,5      r@ " S- S.\\,\-4   5      rAg)Cai  Utility functions to expand configuration directives or special values
(such glob patterns).

We can split the process of interpreting configuration files into 2 steps:

1. The parsing the file contents from strings to value objects
   that can be understand by Python (for example a string with a comma
   separated list of keywords into an actual Python list of strings).

2. The expansion (or post-processing) of these values according to the
   semantics ``setuptools`` assign to them (for example a configuration field
   with the ``file:`` directive should be expanded from a list of file paths to
   a single string with the contents of those files concatenated)

This module focus on the second step, and therefore allow sharing the expansion
functions among several configuration file formats.

**PRIVATE MODULE**: API reserved for setuptools internal usage only.
    )annotationsN)IterableIteratorMapping)ConfigParser)iglob)
ModuleSpecall_suffixes)chain)Path)
ModuleTypeTracebackType)TYPE_CHECKINGAnyCallableTypeVar   )StrPath	same_path)find_package_path)SetuptoolsWarning)DistutilsOptionError)Self)Distribution_K_V_coT)	covariantc                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)StaticModule4   z>Proxy to a module object that avoids executing arbitrary code.c                    [         R                  " [        R                  " UR                  5      R                  5       5      n[        U 5      R                  [        5       5        U ?	g N)
astparsepathlibr   origin
read_bytesvarsupdatelocalsself)r+   namespecmodules       X/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/setuptools/config/expand.py__init__StaticModule.__init__7   s?    7<<4??ABT
&(#I    c              #  f  ^#    U R                   R                   H  m[        T[        R                  5      (       a   U4S jTR
                   5        S h  vN   MB  [        T[        R                  5      (       d  Mc  TR                  (       d  Mv  TR                  TR                  4v   M     g  NY7f)Nc              3  <   >#    U H  oTR                   4v   M     g 7fr"   )value).0target	statements     r/   	<genexpr>1StaticModule._find_assignments.<locals>.<genexpr>?   s     VDU&Y__5DUs   )	r.   body
isinstancer#   Assigntargets	AnnAssignr5   r7   )r+   r8   s    @r/   _find_assignmentsStaticModule._find_assignments<   sp     ))I)SZZ00VIDUDUVVVIs}}55)/// ''99	 *Vs   AB1B/#B1=B1 B1c                   ^  [        U4S jU R                  5        5       5      $ ! [         a   n[        U R                   ST 35      UeSnAff = f)zHAttempt to load an attribute "statically", via :func:`ast.literal_eval`.c              3     >#    U HP  u  p[        U[        R                  5      (       d  M&  UR                  T:X  d  M8  [        R                  " U5      v   MR     g 7fr"   )r<   r#   Nameidliteral_eval)r6   r7   r5   attrs      r/   r9   +StaticModule.__getattr__.<locals>.<genexpr>F   sI      %=MFfchh/ (4:II4E (  ''%=s   $AAAz has no attribute N)nextr@   	ExceptionAttributeErrorr,   )r+   rG   es    ` r/   __getattr__StaticModule.__getattr__C   s]    	P %)%;%;%=  
  	P DII;.@!GHaO	Ps   "& 
AAA N)r,   strr-   r	   returnNone)rQ   z!Iterator[tuple[ast.AST, ast.AST]])rG   rP   )	__name__
__module____qualname____firstlineno____doc__r0   r@   rM   __static_attributes__rO   r2   r/   r   r   4   s    H
:	Pr2   r   c                  ^^ 1 Skn/ nT=(       d    [         R                  " 5       mU  H  m[        U4S jU 5       5      (       ak  [         R                  R	                  [         R                  R                  TT5      5      nUR                  [        U4S j[        USS9 5       5      5        M  [         R                  R                  TT5      R                  [         R                  S5      nUR                  U5        M     U$ )zExpand the list of glob patterns, but preserving relative paths.

:param list[str] patterns: List of glob patterns
:param str root_dir: Path to which globs should be relative
                     (current directory by default)
:rtype: list
>   *?[]{}c              3  *   >#    U H	  oT;   v   M     g 7fr"   rO   )r6   charr5   s     r/   r9    glob_relative.<locals>.<genexpr>^   s     9u}s   c              3     >#    U HC  n[         R                  R                  UT5      R                  [         R                  S 5      v   ME     g7f)/N)ospathrelpathreplacesepr6   rf   root_dirs     r/   r9   rb   b   s;       @ GGOOD(3;;BFFCHH @s   A
AT)	recursiverd   )re   getcwdanyrf   abspathjoinextendsortedr   rg   rh   ri   append)patternsrk   glob_charactersexpanded_values	glob_pathrf   r5   s    `    @r/   glob_relativerx   O   s     5OO&299;H9999Xu(EFI""  %i4 @  77??5(3;;BFFCHD""4( " r2   c                   ^ SSK Jn  [        R                  R	                  T=(       d    [        R
                  " 5       5      mU4S jU" U 5       5       nSR                  U4S j[        U5       5       5      $ )zReturn the content of the files concatenated using ``
`` as str

    This function is sandboxed and won't reach anything outside ``root_dir``

    (By default ``root_dir`` is the current directory).
    r   )always_iterablec              3  b   >#    U H%  n[         R                  R                  TU5      v   M'     g 7fr"   re   rf   rp   rj   s     r/   r9   read_files.<locals>.<genexpr>|   s%     V;U4"'',,x..;Us   ,/
c              3  ^   >#    U H#  n[        UT5      (       d  M  [        U5      v   M%     g 7fr"   )_assert_local
_read_filerj   s     r/   r9   r}   }   s,      6Dx( 	
46s   --)more_itertoolsrz   re   rf   ro   rm   rp   _filter_existing_files)	filepathsrk   rz   
_filepathss    `  r/   
read_filesr   p   sW     /wwx6299;7HV?9;UVJ99 *:6  r2   c              #     #    U  HH  n[         R                  R                  U5      (       a  Uv   M-  [        R                  " SU< S35        MJ     g 7f)NzFile z cannot be found)re   rf   isfiler   emit)r   rf   s     r/   r   r      s?     77>>$J""U4(2B#CD	 s   AAc                l    [        U SS9 nUR                  5       sS S S 5        $ ! , (       d  f       g = f)Nzutf-8)encoding)openread)filepathfs     r/   r   r      s#    	h	)Qvvx 
*	)	)s   %
3c                    [        [        R                  R                  U5      5      [        [        R                  R                  U 5      5      R                  ;  a  SU < SU< S3n[        U5      eg)NzCannot access z (or anything outside )T)r   re   rf   ro   parentsr   )r   rk   msgs      r/   r   r      sW    BGGOOH%&d277??83L.M.U.UUxl*@AN"3''r2   c                z   U=(       d    [         R                  " 5       nU R                  5       R                  S5      nUR	                  5       nSR                  U5      nU=(       d    Sn[        XQU5      n[        XV5      n [        [        XW5      U5      $ ! [         a    [        Xu5      n[        X5      s $ f = f)a  Reads the value of an attribute from a module.

This function will try to read the attributed statically first
(via :func:`ast.literal_eval`), and only evaluate the module if it fails.

Examples:
    read_attr("package.attr")
    read_attr("package.module.attr")

:param str attr_desc: Dot-separated string describing how to reach the
    attribute (see examples above)
:param dict[str, str] package_dir: Mapping of package names to their
    location in disk (represented by paths relative to ``root_dir``).
:param str root_dir: Path to directory containing all the packages in
    ``package_dir`` (current directory by default).
:rtype: str
.r0   )re   rm   stripsplitpoprp   _find_module
_find_specgetattrr   rJ   
_load_spec)		attr_descpackage_dirrk   
attrs_path	attr_namemodule_namerf   r-   r.   s	            r/   	read_attrr      s    , &299;H"((-J I((:&K+K(;Dk(D*|K6	BB *D.v))*s   B  B:9B:c                    [         R                  R                  X5      nU=(       d    [         R                  R                  U 5      nUc  [	        U 5      eU$ r"   )	importlibutilspec_from_file_location	find_specModuleNotFoundError)r   module_pathr-   s      r/   r   r      sD    >>11+KD89>>++K8D|!+..Kr2   c                &   [        U SU5      nU[        R                  ;   a  [        R                  U   $ [        R                  R                  U 5      nU[        R                  U'   U R                  c   eU R                  R                  U5        U$ )NrS   )r   sysmodulesr   r   module_from_specloaderexec_module)r-   r   r,   r.   s       r/   r   r      st    4[1Ds{{{{4  ^^,,T2FCKK;;"""KKF#Mr2   c                   ^ [        X=(       d    0 U5      m[        R                  " U4S j[        5        5       5      n[	        S U 5       S5      $ )a  Find the path to the module named ``module_name``,
considering the ``package_dir`` in the build configuration and ``root_dir``.

>>> tmp = getfixture('tmpdir')
>>> _ = tmp.ensure("a/b/c.py")
>>> _ = tmp.ensure("a/b/d/__init__.py")
>>> r = lambda x: x.replace(str(tmp), "tmp").replace(os.sep, "/")
>>> r(_find_module("a.b.c", None, tmp))
'tmp/a/b/c.py'
>>> r(_find_module("f.g.h", {"": "1", "f": "2", "f.g": "3", "f.g.h": "a/b/d"}, tmp))
'tmp/a/b/d/__init__.py'
c              3  t   >#    U H.  nT U 3[         R                  R                  TS U 35      4v   M0     g7f)r0   Nr|   )r6   ext
path_starts     r/   r9   _find_module.<locals>.<genexpr>   s<      %!C <u	rww||J(3%8HIJ!s   58c              3  p   #    U H-  n[         R                  R                  U5      (       d  M)  Uv   M/     g 7fr"   )re   rf   r   )r6   xs     r/   r9   r      s!     <Jq"''..*;Js   '6	6N)r   r   from_iterabler
   rI   )r   r   rk   
candidatesr   s       @r/   r   r      sJ     #;0Ar8LJ$$ %>% J <J<dCCr2   c                    U=(       d    [         R                  " 5       nU R                  S5      nXS-   S nU SU n[        XQU5      n[	        [        XV5      U5      n[        Xt5      $ )z@Given a qualified class name, return the associated class objectr      N)re   rm   rfindr   r   r   r   )qualified_class_namer   rk   idx
class_namepkg_namerf   r.   s           r/   resolve_classr      sf     &299;H

$
$S
)C%Agi0J#DS)Hx8D
82H=F6&&r2   c           
     l    U R                  5        VVs0 sH  u  p4U[        XAU5      _M     snn$ s  snnf )zGiven a dictionary mapping command names to strings for qualified class
names, apply :func:`resolve_class` to the dict values.
)itemsr   )valuesr   rk   kvs        r/   cmdclassr      s2     DJ<<>R>41A}QX66>RRRs   0)
namespacesfill_package_dirrk   c                  ^ SSK JnJn  SSKJn  U (       d  SSKJn  OSSKJn  U=(       d    [        R                  nUR                  SS/5      n/ n	Uc  0 OUn[        U" U" U5      5      5      m[        T5      S:X  a1  [        U4S	 jSU4 5       5      (       a  UR                  S
TS   5        T H  n
[        X*5      nUR                  " U40 UD6nU	R!                  U5        U(       d  M;  UR#                  S
5      U
:X  a  MR  [        R$                  R'                  X5      (       a  Mx  UR)                  U" X5      5        M     U	$ )a  Works similarly to :func:`setuptools.find_packages`, but with all
arguments given as keyword arguments. Moreover, ``where`` can be given
as a list (the results will be simply concatenated).

When the additional keyword argument ``namespaces`` is ``True``, it will
behave like :func:`setuptools.find_namespace_packages`` (i.e. include
implicit namespaces as per :pep:`420`).

The ``where`` argument will be considered relative to ``root_dir`` (or the current
working directory when ``root_dir`` is not given).

If the ``fill_package_dir`` argument is passed, this function will consider it as a
similar data structure to the ``package_dir`` configuration parameter add fill-in
any missing package location.

:rtype: list
r   )rz   unique_everseen)construct_package_dir)PackageFinder)PEP420PackageFinderwherer   r   c              3  J   >#    U H  n[        TS    U5      (       + v   M     g7f)r   N)
_same_path)r6   r   searchs     r/   r9    find_packages.<locals>.<genexpr>.  s"     VoJvay!$< < <os    # )r   rz   r   setuptools.discoveryr   r   r   re   curdirr   listlenall
setdefault
_nest_pathfindrq   getrf   samefiler)   )r   r   rk   kwargsrz   r   r   r   r   packagesrf   package_pathpkgsr   s                @r/   find_packagesr     s   0 @: 6M$299HJJw&EH-5r;K//%"89:F
6{aCVsHoVVV##Bq	2!(1!!,9&94  $,0@0@0X0X##$9$$EF  Or2   c                    US;   a  U O[         R                  R                  X5      n[         R                  R                  U5      $ )N>   r   r   )re   rf   rp   normpath)parentrf   s     r/   r   r   =  s2    Y&6BGGLL,FD77D!!r2   c                    [        U 5      (       a  U " 5       OU n[        U[        5      (       a  U$ [        US5      (       a  SR	                  [        [        U5      5      $ SU-  $ )zXWhen getting the version directly from an attribute,
it should be normalised to string.
__iter__r   z%s)callabler<   rP   hasattrrp   map)r5   _values     r/   versionr   B  sT     !UWUF&#vz""xxC())&=r2   c                :    SU ;   a  U R                  S5      U S'   U $ )NrZ   r   )r   )package_datas    r/   canonic_package_datar   O  s%    
l'++C0Rr2   c           	         [        U [        5      (       a  U $ U R                  5        VVs/ sH  u  p#U[        X15      4PM     snn$ s  snnf )zFor compatibility with ``setup.py``, ``data_files`` should be a list
of pairs instead of a dict.

This function also expands glob patterns.
)r<   r   r   rx   )
data_filesrk   destrt   s       r/   canonic_data_filesr   U  sS     *d## )..00ND 
}X010  s   Ac           	        [        SSS9n[        Ul        UR                  X5        UR	                  5        VVs0 sH  u  p4U[        UR	                  5       5      _M!     nnnUR                  UR                  S5        U$ s  snnf )a+  Given the contents of entry-points file,
process it into a 2-level dictionary (``dict[str, dict[str, str]]``).
The first level keys are entry-point groups, the second level keys are
entry-point names, and the second level values are references to objects
(that correspond to the entry-point value).
N)=)default_section
delimiters)r   rP   optionxformread_stringr   dictr   r   )texttext_sourceparserr   r   groupss         r/   entry_pointsr   f  so     $6BFF
t)-3\\^<^TQaaggi ^F<
JJv%%t,M =s   %B c                  f    \ rS rSrSrSS jrS rSS jr      SS jrSS jr	\
SS j5       rS	rg
)EnsurePackagesDiscoveredix  a  Some expand functions require all the packages to already be discovered before
they run, e.g. :func:`read_attr`, :func:`resolve_class`, :func:`cmdclass`.

Therefore in some cases we will need to run autodiscovery during the evaluation of
the configuration. However, it is better to postpone calling package discovery as
much as possible, because some parameters can influence it (e.g. ``package_dir``),
and those might not have been processed yet.
c                    Xl         SU l        g )NF)_dist_called)r+   distributions     r/   r0   !EnsurePackagesDiscovered.__init__  s    !
r2   c                h    U R                   (       d!  SU l         U R                  R                  SS9  gg)zBTrigger the automatic package discovery, if it is still necessary.TF)r,   N)r  r  set_defaultsr+   s    r/   __call__!EnsurePackagesDiscovered.__call__  s*    ||DLJJ###/ r2   c                    U $ r"   rO   r	  s    r/   	__enter__"EnsurePackagesDiscovered.__enter__  s    r2   c                p    U R                   (       a%  U R                  R                  R                  5         g g r"   )r  r  r  analyse_name)r+   exc_type	exc_value	tracebacks       r/   __exit__!EnsurePackagesDiscovered.__exit__  s&     <<JJ##002 r2   c                J    U " 5         U R                   R                  nUc  0 $ U$ r"   )r  r   )r+   pkg_dirs     r/   _get_package_dir)EnsurePackagesDiscovered._get_package_dir  s%    **((_r1'1r2   c                ,    [        U R                  5      $ )zCProxy to ``package_dir`` that may trigger auto-discovery when used.)LazyMappingProxyr  r	  s    r/   r   $EnsurePackagesDiscovered.package_dir  s       5 566r2   )r  r  N)r  r   rQ   rR   )rQ   r   )r  ztype[BaseException] | Noner  zBaseException | Noner  zTracebackType | None)rQ   zMapping[str, str])rS   rT   rU   rV   rW   r0   r
  r  r  r  propertyr   rX   rO   r2   r/   r  r  x  sP    03,3 (3 (	32
 7 7r2   r  c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)r  i  a]  Mapping proxy that delays resolving the target object, until really needed.

>>> def obtain_mapping():
...     print("Running expensive function!")
...     return {"key": "value", "other key": "other value"}
>>> mapping = LazyMappingProxy(obtain_mapping)
>>> mapping["key"]
Running expensive function!
'value'
>>> mapping["other key"]
'other value'
c                    Xl         S U l        g r"   _obtainr   )r+   obtain_mapping_values     r/   r0   LazyMappingProxy.__init__  s    +15r2   c                ^    U R                   c  U R                  5       U l         U R                   $ r"   )r   r!  r	  s    r/   _targetLazyMappingProxy._target  s#    ;;,,.DK{{r2   c                (    U R                  5       U   $ r"   )r%  )r+   keys     r/   __getitem__LazyMappingProxy.__getitem__  s    ||~c""r2   c                4    [        U R                  5       5      $ r"   )r   r%  r	  s    r/   __len__LazyMappingProxy.__len__  s    4<<>""r2   c                4    [        U R                  5       5      $ r"   )iterr%  r	  s    r/   r   LazyMappingProxy.__iter__  s    DLLN##r2   r   N)r"  z Callable[[], Mapping[_K, _V_co]]rQ   rR   )rQ   zMapping[_K, _V_co])r(  r   rQ   r   )rQ   int)rQ   zIterator[_K])rS   rT   rU   rV   rW   r0   r%  r)  r,  r   rX   rO   r2   r/   r  r    s     6
##$r2   r  r"   )rt   zIterable[str]rk   StrPath | NonerQ   	list[str])r   zStrPath | Iterable[StrPath]rk   r2  rQ   rP   )r   zIterable[StrPath]rQ   zIterator[StrPath])r   zbytes | StrPathrQ   rP   )r   r   rk   rP   )NN)r   rP   r   Mapping[str, str] | Nonerk   r2  rQ   r   )r   rP   r   r2  rQ   r	   )r-   r	   r   rP   rQ   r   )r   rP   r   r4  rk   r   rQ   z
str | None)r   rP   r   r4  rk   r2  rQ   r   )r   zdict[str, str]r   r4  rk   r2  rQ   zdict[str, Callable])r   zdict[str, str] | Nonerk   r2  rQ   r3  )r   r   rf   r   rQ   rP   )r5   z$Callable | Iterable[str | int] | strrQ   rP   )r   r   rQ   r   )r   zlist | dictrk   r2  rQ   zlist[tuple[str, list[str]]])zentry-points)r   rP   r   rP   rQ   zdict[str, dict[str, str]])BrW   
__future__r   r#   r   re   r%   r   collections.abcr   r   r   configparserr   globr   importlib.machineryr	   r
   	itertoolsr   r   typesr   r   typingr   r   r   r   _pathr   r   r   	discoveryr   warningsr   distutils.errorsr   typing_extensionsr   setuptools.distr   r   r   r   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  rO   r2   r/   <module>rC     s8  ( # 
  	  
 7 7 %  8   + 8 8 4 ) ( 1&,T]4(P P8 9='5D HL*6D(E
 -1##*#*)#* #* 		#*LDD#;DGNDD2 -1#'')' ' 	'$ -1#SS)S S 	S .2#	4 ,4 	4 4n"

 9='5 $ #1
$(7 (7V$wr5y) $r2   