-X yL (dZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZmZmZmZmZmZmZmZmZmZmZmZddlmZdd lmZdd l m!Z!d d l"m#Z$erdd l%m&Z&ddl'm(Z(ddl)m*Z*ej+Z,ee-ej.fZ/edZ0eddZ1GddZ2 d@dee-dee/dee-fdZ3d@dee-e4ee/fde-fdZ5dee/dee/fdZ6dee4e/fde-fdZ7de/de-fdZ8 dAd e-d!eee-e-fdee/fd"Z9d#e-d$ee/de fd%Z:d&e d#e-defd'Z;d#e-d!eee-e-fde/dee/ee-e-ffd(Z< dAd)e-d!eee-e-fdee/defd*Z= dAd+ee-e-fd!eee-e-fdee/dee-effd,Z>dddd-d.eee-e-fdee/dee-fd/Z?d0e/d1e/de-fd2Z@d3eeeee-eAfe-fde-fd4ZBd5eCdeCfd6ZD d@d7eeEeCfdee/deee-ee-ffd8ZFdBd:e-dee-eCffd;ZGGd<d=ZHGd>d?ee0e1fZIdS)CaiUtility 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. N)iglob) ConfigParser) ModuleSpec)chain) TYPE_CHECKINGCallableDictIterableIteratorListMappingOptionalTupleTypeVarUnioncast)Path) ModuleType)DistutilsOptionError) same_path) Distribution)ConfigDiscovery)DistributionMetadata_K_VT) covariantcdeZdZdZdedefdZdeee j e j ffdZ dZ dS) StaticModulez>Proxy to a module object that avoids executing arbitrary code.namespecctjtj|j}t |t|` dSN) astparsepathlibrorigin read_bytesvarsupdatelocalsself)r,r r!modules /builddir/build/BUILDROOT/alt-python311-setuptools-65.6.3-2.el9.x86_64/opt/alt/python311/lib/python3.11/site-packages/setuptools/config/expand.py__init__zStaticModule.__init__BsP7< 44??AABB T &((### IIIreturnc#K|jjD]gttjrfdjDEd{V6ttjrjrjjfVhdS)Nc3*K|] }|jfVdSr#value).0target statements r. z1StaticModule._find_assignments..Js*VV&VY_5VVVVVVr0) r-body isinstancer$Assigntargets AnnAssignr5r7)r,r8s @r._find_assignmentszStaticModule._find_assignmentsGs) : :I)SZ00 :VVVVIDUVVVVVVVVVVVIs}55 :)/ : '9999  : :r0c tfd|DS#t$r}t|jd|d}~wwxYw)zHAttempt to load an attribute "statically", via :func:`ast.literal_eval`.c3K|]@\}}t|tjr!|jk*tj|VAdSr#)r;r$Nameid literal_eval)r6r7r5attrs r.r9z+StaticModule.__getattr__..Qsa!FEfch//5;I4E4E ''4E4E4E4Er0z has no attribute N)nextr? ExceptionAttributeErrorr )r,rEes ` r. __getattr__zStaticModule.__getattr__Ns P%)%;%;%=%=   P P P DI!G!G!G!GHHa O Ps,0 AAAN) __name__ __module__ __qualname____doc__strrr/r rr$ASTr?rJr0r.rr?s~HHS  :8E#'372B,C#D:::: P P P P Pr0rpatternsroot_dirr1c hd}g}ptj|D]tfd|Dr{tjtj}|tfdt|dDtj  tj d}| ||S)aExpand 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 >*{}?[]c3 K|]}|vV dSr#rQ)r6charr5s r.r9z glob_relative..js'99tu}999999r0c3K|]B}tj|tjdVCdS)/N)ospathrelpathreplacesepr6r`rSs r.r9z glob_relative..msY*>*>h//77DD*>*>*>*>*>*>r0T) recursiver^) r_getcwdanyr`abspathjoinextendsortedrrarbrcappend)rRrSglob_charactersexpanded_values glob_pathr`r5s ` @r. glob_relativerpZs!544OO&29;;H ) ) 9999999 9 9 ) Xu(E(EFFI  " "6*>*>*>*>!)t<<<*>*>*>$>$> ? ? ? ? 7??5(33;;BFCHHD  " "4 ( ( ( ( r0 filepathscddlm}tjptjfd||D}dfdt|DS)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_iterablec3XK|]$}tj|V%dSr#)r_r`rirds r.r9zread_files..s3VV4"',,x..VVVVVVr0 c3VK|]#}t|t|V$dSr#) _assert_local _read_filerds r.r9zread_files..sO  x ( (4r0) setuptools.extern.more_itertoolsrsr_r`rhrfri_filter_existing_files)rqrSrs _filepathss ` r. read_filesr|ysA@@@@@wx629;;77HVVVV??9;U;UVVVJ 99*:66  r0c#K|D]>}tj|r|V&tjd|d?dS)NzFile z cannot be found)r_r`isfilewarningswarn)rqr`s r.rzrzs_<< 7>>$   <JJJJ M:$::: ; ; ; ; < 1 1+{ K KD  89>++K88D |!+... Kr0r!ct|d|}|tjvrtj|Stj|}|tj|<|j||S)NrK)rsysmodulesrrmodule_from_specloader exec_module)r!rr r-s r.rrsi 4[ 1 1D s{{4  ^ , ,T 2 2FCKKF### Mr0c|}|d}|r|d|vr||d}|dd}t|dkr/tj||d}|d}n|}d|g|dd}n*d|vr&tj||d}tjj|g|dR}t |dtj|dft|d } td | Dd} || |fS) a0Given a module (that could normally be imported by ``module_name`` after the build is complete), find the path to the parent directory where it is contained and the canonical name that could be used to import it considering the ``package_dir`` in the build configuration and ``root_dir`` rrr^Nz.pyz __init__.pyz.*c3XK|]%}tj|!|V&dSr#)r_r`r~)r6xs r.r9z_find_module..s5CCa1B1BCCCCCCCr0) rrsplitlenr_r`rirrrF) rrrS parent_path module_parts custom_pathparts parent_module path_start candidatesrs r.rrsoK$$S))L B ?k ) )%l1o6K&&sA..E5zzA~~ gll8U1X>> %a + ((M#EL4D#EFFKK ;  ',,xRAAKkCK,=,=c,B,BCCCJ    RW\\*mDDE   JCC:CCCTJJK  [ 00r0qualified_class_namec |ptj}|d}||dzd}|d|}t|||\}}}t t |||} t | |S)z@Given a qualified class name, return the associated class objectrrN)r_rfrfindrrrr) rrrSidx class_namepkg_namerr`rr-s r. resolve_classrs &29;;H  $ $S ) )C%cAgii0J#DSD)H&28[(&S&S#L$  ;55{ C CF 6: & &&r0valuescHfd|DS)zGiven a dictionary mapping command names to strings for qualified class names, apply :func:`resolve_class` to the dict values. c:i|]\}}|t|SrQ)r)r6kvrrSs r. zcmdclass..s+ R R R41aA}Q X66 R R Rr0)items)rrrSs ``r.cmdclassr s, S R R R R6<<>> R R RRr0) namespacesfill_package_dirrSrc  ddlm}ddlm}m}|rddlm}nddlm}|p tj}| ddg}g} |in|}t||| t d kr9t fd d|fDr| d d D]} t|| } |j| fi|} | | | rX|d | ks?tj| |s||| | | S) aWorks 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)construct_package_dir)unique_everseenrs)PEP420PackageFinder) PackageFinderwhererNrc3FK|]}td| VdS)rN) _same_path)r6rsearchs r.r9z find_packages..=s4VVJvay!$<$< <VVVVVVr0r)setuptools.discoveryrryrrsrrr_curdirrlistrall setdefault _nest_pathfindrjgetr`samefiler*)rrrSkwargsrrrsrrpackagesr` package_pathpkgsrs @r. find_packagesrs0;:::::QQQQQQQQ7MMMMMMM666666$29H JJw & &EH-5rr;K ////%"8"899 : :F 6{{aCVVVVsHoVVVVV##Bq 222GG!(D11 !}!,99&99  G   $ $ , ,w h77 -  # #$9$9$$E$E F F F Or0parentr`c|dvr|ntj||}tj|S)N>rr)r_r`rinormpath)rr`s r.rrMs;Y&&66BGLL,F,FD 7  D ! !!r0r5cBt|r |}ttttt f|}t |ts>t|dr)dtt|}nd|z}|S)z`When getting the version directly from an attribute, it should be normalised to string. __iter__rz%s) callablerr rrOintr;hasattrrimapr4s r.versionrRs %S/*E 2 2E eS ! !! 5* % % !HHSe__--EE5LE Lr0 package_datac>d|vr|d|d<|S)NrUr)r)rs r.canonic_package_datards+ l'++C00 R r0 data_filescrt|tr|Sfd|DS)zFor compatibility with ``setup.py``, ``data_files`` should be a list of pairs instead of a dict. This function also expands glob patterns. c:g|]\}}|t|fSrQ)rp)r6destrRrSs r. z&canonic_data_files..us<    D( }Xx001   r0)r;rr)rrSs `r.canonic_data_filesrjsT*d##    (..00   r0 entry-pointstextctdd}t|_|||d|D}||jd|S)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 delimiterscXi|]'\}}|t|(SrQ)dictr)r6rrs r.rz entry_points..s, < < >> 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' obtain_mapping_valuec"||_d|_dSr#)_obtain_value)r,rs r.r/zLazyMappingProxy.__init__s+ 15 r0r1cP|j||_|jSr#)rrrs r._targetzLazyMappingProxy._targets! ; ,,..DK{r0keyc6||Sr#)r)r,rs r. __getitem__zLazyMappingProxy.__getitem__s||~~c""r0cDt|Sr#)rrrs r.__len__zLazyMappingProxy.__len__s4<<>>"""r0cDt|Sr#)iterrrs r.rzLazyMappingProxy.__iter__sDLLNN###r0N)rKrLrMrNrr rrr/rr!rr#r rrQr0r.rrs  6Xb'"b&/6I-J6666R #r#b#########$(2,$$$$$$r0rr#)NN)r)JrNr$rrr_r&rrglobr configparserrimportlib.machineryr itertoolsrtypingrrr r r r r rrrrrrtypesrdistutils.errorsr_pathrrsetuptools.distrrrdistutils.distr from_iterable chain_iterrOPathLike_Pathrrrrpbytesr|rzrxrwrrrrrrrrrrrrrrrrrrQr0r.r5s&   %%%%%%******                            111111++++++4,,,,,,444444333333   c2; WT]] WTT"""PPPPPPPP8:>sm'/ #Y>%UHUO ;<PS$1JO1 5(3- $%1111H04 $ ' ' ''#s(+, 'uo ' ' ' ' '$04 $SS cNS'#s(+,SuoS #x- SSSS15 $ 333tCH~.3uo 3  #Y 3333l"u"E"c"""" 58E#s(O#