|PؚZdZddlmZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl m Z ddlmZddlmZmZddlmZdd lmZdd lmZmZdd lmZmZmZmZd d lmZd dl m!Z!m"Z#d dl$m%Z%d dl&m'Z'ddl(m)Z)er ddl*m+Z+ddl,m-Z-edZ.eddZ/GddZ0 d\d]d Z1 d\d^d$Z2d_d'Z3d`d*Z4dad,Z5 dbdcd1Z6ddd5Z7ded8Z8dfd:Z9 dbdgd=Z: dbdhdAZ;ddddBdidEZdldNZ? d\dmdRZ@ dndodWZAGdXdYZBGdZd[e e.e/fZCdS)paiUtility 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)IterableIteratorMapping) ConfigParser)iglob) ModuleSpec all_suffixes)chain)Path) ModuleType TracebackType) TYPE_CHECKINGAnyCallableTypeVar)_static)StrPath same_path)find_package_path)SetuptoolsWarning)DistutilsOptionError)Self) Distribution_K_V_coT) covariantc*eZdZdZddZdd Zdd Zd S) StaticModulez>Proxy to a module object that avoids executing arbitrary code.namestrspecr returnNonectjtj|j}t |t|` dSN) astparsepathlibr origin read_bytesvarsupdatelocalsself)r0r!r#modules j/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/setuptools/config/expand.py__init__zStaticModule.__init__8sP7< 44??AABB T &((### III!Iterator[tuple[ast.AST, ast.AST]]c#K|jjD]gttjrfdjDEd{V6ttjrjrjjfVhdS)Nc3*K|] }|jfVdSr')value).0target statements r2 z1StaticModule._find_assignments..@s*VV&VY_5VVVVVVr4) r1body isinstancer(Assigntargets AnnAssignr8r:)r0r;s @r2_find_assignmentszStaticModule._find_assignments=s) : :I)SZ00 :VVVVIDUVVVVVVVVVVVIs}55 :)/ : '9999  : :r4attrc 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)r9r:r8rCs r2r<z+StaticModule.__getattr__..Gsa!FEfch//5;I4E4E ''4E4E4E4Er4z has no attribute N)nextrB ExceptionAttributeErrorr!)r0rCes ` r2 __getattr__zStaticModule.__getattr__Ds P%)%;%;%=%=   P P P DI!G!G!G!GHHa O Ps,0 AAAN)r!r"r#r r$r%)r$r5)rCr")__name__ __module__ __qualname____doc__r3rBrMr4r2r r 5s\HH :::: P P P P P Pr4r patterns Iterable[str]root_dirStrPath | Noner$ list[str]c 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'rR)r9charr8s r2r<z glob_relative.._s'99tu}999999r4c3K|]B}tj|tjdVCdS)/N)ospathrelpathreplacesepr9rdrUs r2r<z glob_relative..csYGOOD(33;;BFCHHr4T) recursiverb) rcgetcwdanyrdabspathjoinextendsortedrrerfrgappend)rSrUglob_charactersexpanded_values glob_pathrdr8s ` @r2 glob_relativertPs 544OO&29;;H)) 9999999 9 9 ) Xu(E(EFFI  " " %i4 @ @ @    7??5(33;;BFCHHD  " "4 ( ( ( ( r4 filepathsStrPath | Iterable[StrPath]r"cddlm}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'rcrdrmrhs r2r<zread_files..}s3VV4"',,x..VVVVVVr4 c3VK|]#}t|t|V$dSr') _assert_local _read_filerhs r2r<zread_files..~sO  x ( (4r4)more_itertoolsrxrcrdrlrjrm_filter_existing_files)rurUrx _filepathss ` r2 read_filesrqs/.....wx629;;77HVVVV??9;U;UVVVJ 99*:66  r4Iterable[StrPath]Iterator[StrPath]c#K|D]>}tj|r|V&tjd|d?dS)NzFile z cannot be found)rcrdisfileremit)rurds r2rrseEE 7>>$   EJJJJ  "#C4#C#C#C D D D D EEr4filepathbytes | StrPathct|d5}|cdddS#1swxYwYdS)Nzutf-8)encoding)openread)rfs r2r~r~s h ) ) )Qvvxxs 377rcttj|ttj|jvrd|d|d}t |dS)NzCannot access z (or anything outside )T)r rcrdrlparentsr)rrUmsgs r2r}r}sg BGOOH % %&&d27??83L3L.M.M.UUUNxNNNNN"3''' 4r4 attr_desc package_dirMapping[str, str] | Nonerc|ptj}|d}|}d|}|pd}t |||}t||} tt|||}tj |S#t$r#t||} t| |cYSwxYw)aReads 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 .r3)rcrjstripsplitpoprm _find_module _find_specgetattrr rattempt_conversionrJ _load_spec) rrrU attrs_path attr_name module_namerdr#r8r1s r2 read_attrrs,&29;;H""((--J  I((:&&K+K  [( ; ;D k4 ( (D* [$77CC)%000 ***D+..vy)))))*s 1B>>*C+*C+r module_pathr ctj||}|ptj|}|t ||Sr') importlibutilspec_from_file_location find_specModuleNotFoundError)rrr#s r2rrsK > 1 1+{ K KD  89>++K88D |!+... Kr4r#r c t|d|}|tjvrtj|Stj|}|tj|<|jJ|j||S)NrN)rsysmodulesrrmodule_from_specloader exec_module)r#rr!r1s r2rrsw 4[ 1 1D s{{4  ^ , ,T 2 2FCK ; " " "KF### Mr4 str | Nonect||pi|tjfdtD}t d|DdS)aFind 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' c3jK|]-}|tjd|fV.dS)r3Nrz)r9ext path_starts r2r<z_find_module..s`%%     rw||J8H38H8HIIJ%%%%%%r4c3XK|]%}tj|!|V&dSr')rcrdr)r9xs r2r<z_find_module..s5<>%%%J <zcmdclass..s+ R R R41aA}Q X66 R R Rr4)items)rrrUs ``r2cmdclassrs, S R R R R6<<>> R R RRr4) namespacesfill_package_dirrUrdict[str, str] | Nonec  ddlm}m}ddlm}|sddlm}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)rxunique_everseen)construct_package_dir) PackageFinder)PEP420PackageFinderwhererNrc3FK|]}td| VdS)rN) _same_path)r9rsearchs r2r<z find_packages..1s4VVJvay!$<$< <VVVVVVr4)rrxrsetuptools.discoveryrrrrccurdirrlistlenall setdefault _nest_pathfindrngetrdsamefiler.)rrrUkwargsrxrrrrpackagesrd package_pathpkgsrs @r2 find_packagesr s0@???????:::::: N6666666MMMMMM$29H JJw & &EH-5rr;K ////%"8"899 : :F 6{{aCVVVVsHoVVVVV##Bq 222GG!(D11 !}!,99&99  G   $ $ , ,0@0@x0X0X ,  # #$9$9$$E$E F F F Or4parentrdc|dvr|ntj||}tj|S)N>rr)rcrdrmnormpath)rrds r2rr@s;Y&&66BGLL,F,FD 7  D ! !!r4r8$Callable | Iterable[str | int] | strct|r |n|}t|tr|St|dr(dt t|S|S)z`When getting the version directly from an attribute, it should be normalised to string. __iter__r)callabler>r"hasattrrmmap)r8_values r2versionrEsk! 2UUWWWUF&# vz""*xxC(()));r4 package_datadictc>d|vr|d|d<|S)NrYr)r)rs r2canonic_package_datarRs+ l'++C00 R r4 data_files list | dictlist[tuple[str, list[str]]]crt|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|fSrR)rt)r9destrSrUs r2 z&canonic_data_files..cs<    D( }Xx001   r4)r>rr)rrUs `r2canonic_data_filesrXsT*d##    (..00   r4 entry-pointstext text_sourcedict[str, dict[str, str]]ctdd}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|(SrR)rr)r9rrs r2rz entry_points..vs, < < >> 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_value Callable[[], Mapping[_K, _V_co]]r$r%c"||_d|_dSr')_obtainr)r0r*s r2r3zLazyMappingProxy.__init__s+ 15 r4Mapping[_K, _V_co]cP|j||_|jSr')rr-rs r2_targetzLazyMappingProxy._targets! ; ,,..DK{r4keyrrc6||Sr')r0)r0r1s r2 __getitem__zLazyMappingProxy.__getitem__s||~~c""r4intcDt|Sr')rr0rs r2__len__zLazyMappingProxy.__len__s4<<>>"""r4 Iterator[_K]cDt|Sr')iterr0rs r2rzLazyMappingProxy.__iter__sDLLNN###r4N)r*r+r$r%)r$r.)r1rr$r)r$r4)r$r7) rNrOrPrQr3r0r3r6rrRr4r2r'r's  6666 ########$$$$$$r4r'r')rSrTrUrVr$rW)rurvrUrVr$r")rurr$r)rrr$r")rrrUr")NN)rr"rrrUrVr$r)rr"rrVr$r )r#r rr"r$r )rr"rrrUrr$r)rr"rrrUrVr$r)rrrrrUrVr$r)rrrUrVr$rW)rrrdrr$r")r8rr$r")rrr$r)rrrUrVr$r)r)rr"rr"r$r)DrQ __future__rr(rrcr*rcollections.abcrrr configparserrglobrimportlib.machineryr r itertoolsr r typesr rtypingrrrrrr_pathrrr discoveryrwarningsrdistutils.errorsrtyping_extensionsrsetuptools.distrrrr rtrrr~r}rrrrrrrrrrrr rr'rRr4r2rHs(#"""""   7777777777%%%%%%88888888++++++++88888888888844444444))))))((((((111111-&&&&&&,,,,,, WT]]4(((PPPPPPPP89=DHL(EEEE -1#%*%*%*%*%*PDDDD2-1# ' ' ' ' '$-1#SSSSS.2# 444444n""""    9=$#1$(7(7(7(7(7(7(7(7V$$$$$wr5y)$$$$$r4