:Qg@ $dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZmZmZmZmZmZmZmZmZmZmZmZddlmZdd lmZdd lmZd d l m!Z"d d l#m$Z$erddl%m&Z&ddl'm(Z(ddl)m*Z*e j+Z,ee-ej.fZ/edZ0eddZ1GddZ2 dAdee-dee/dee-fdZ3dAdee-e4ee/fde-fdZ5dee/dee/fdZ6dee4e/fde-fdZ7de/de-fd Z8 dBd!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< dBd*e-d"eee-e-fdee/defd+Z= dBd,ee-e-fd"eee-e-fdee/dee-effd-Z>dddd.d/eee-e-fdee/dee-fd0Z?d1e/d2e/de-fd3Z@d4eeeee-eAfe-fde-fd5ZBd6eCdeCfd7ZD dAd8eeEeCfdee/deee-ee-ffd9ZFdCd;e-dee-eCffd<ZGGd=d>ZHGd?d@ee0e1fZIdS)DaiUtility 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)SetuptoolsWarning) 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 x/builddir/build/BUILD/imunify360-venv-2.5.0/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/config/expand.py__init__zStaticModule.__init__AsP7< 44??AABB T &((### IIIreturnc#K|jjD]gttjrfdjDEd{V6ttjrjrjjfVhdS)Nc3*K|] }|jfVdSr$value).0target statements r/ z1StaticModule._find_assignments..Is*VV&VY_5VVVVVVr1) r.body isinstancer%Assigntargets AnnAssignr6r8)r-r9s @r/_find_assignmentszStaticModule._find_assignmentsFs) : :I)SZ00 :VVVVIDUVVVVVVVVVVVIs}55 :)/ : '9999  : :r1c 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)r7r8r6attrs r/r:z+StaticModule.__getattr__..Psa!FEfch//5;I4E4E ''4E4E4E4Er1z has no attribute N)nextr@ ExceptionAttributeErrorr!)r-rFes ` r/ __getattr__zStaticModule.__getattr__Ms P%)%;%;%=%=   P P P DI!G!G!G!GHHa O Ps,0 AAAN) __name__ __module__ __qualname____doc__strrr0r rr%ASTr@rKr1r/r r >s~HHS  :8E#'372B,C#D:::: P P P P Pr1r patternsroot_dirr2c 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)r7charr6s r/r:z glob_relative..hs'99tu}999999r1c3K|]B}tj|tjdVCdS)/N)ospathrelpathreplacesepr7rarTs r/r:z glob_relative..lsYGOOD(33;;BFCHHr1T) recursiver_) r`getcwdanyraabspathjoinextendsortedrrbrcrdappend)rSrTglob_charactersexpanded_values glob_pathrar6s ` @r/ glob_relativerqYs 544OO&29;;H)) 9999999 9 9 ) Xu(E(EFFI  " " %i4 @ @ @    7??5(33;;BFCHHD  " "4 ( ( ( ( r1 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`rarjres r/r:zread_files..s3VV4"',,x..VVVVVVr1 c3VK|]#}t|t|V$dSr$) _assert_local _read_fileres r/r:zread_files..sO  x ( (4r1) setuptools.extern.more_itertoolsrtr`rarirgrj_filter_existing_files)rrrTrt _filepathss ` r/ read_filesr}zsA@@@@@wx629;;77HVVVV??9;U;UVVVJ 99*:66  r1c#K|D]>}tj|r|V&tjd|d?dS)NzFile z cannot be found)r`raisfileremit)rrras r/r{r{seEE 7>>$   EJJJJ  "#C4#C#C#C D D D D EEr1filepathct|d5}|cdddS#1swxYwYdS)Nzutf-8)encoding)openread)rfs r/ryrys h ) ) )Qvvxxs 377cttj|ttj|jvrd|d|d}t |dS)NzCannot access z (or anything outside )T)rr`rariparentsr)rrTmsgs r/rxrxsg BGOOH % %&&d27??83L3L.M.M.UUUNxNNNNN"3''' 4r1 attr_desc package_dirc|ptj}|d}|}d|}|pd}t |||\}}}t||} tt|||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 .r0) r`rgstripsplitpoprj _find_module _find_specgetattrr rH _load_spec) rrrT attrs_path attr_name module_name _parent_pathrar"r.s r/ read_attrrs,&29;;H""((--J  I((:&&K+K&2; X&V&V#L$ k4 ( (D*|K66 BBB ***D+..vy)))))*sB..*CCr module_pathctj||}|ptj|}|t ||Sr$) importlibutilspec_from_file_location find_specModuleNotFoundError)rrr"s r/rrsK > 1 1+{ K KD  89>++K88D |!+... Kr1r"ct|d|}|tjvrtj|Stj|}|tj|<|j||S)NrL)rsysmodulesrrmodule_from_specloader exec_module)r"rr!r.s r/rrsi 4[ 1 1D s{{4  ^ , ,T 2 2FCKKF### Mr1c|}|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`rar)r7xs r/r:z_find_module..s5CCa1B1BCCCCCCCr1) rrsplitlenr`rarjrrrG) rrrT 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  [ 00r1qualified_class_namec |ptj}|d}||dzd}|d|}t|||\}}}t t |||} t | |S)z@Given a qualified class name, return the associated class objectrrN)r`rgrfindrrrr) rrrTidx class_namepkg_namerrarr.s r/ resolve_classrs &29;;H  $ $S ) )C%cAgii0J#DSD)H&28[(&S&S#L$  ;55{ C CF 6: & &&r1valuescHfd|DS)zGiven a dictionary mapping command names to strings for qualified class names, apply :func:`resolve_class` to the dict values. c:i|]\}}|t|SrR)r)r7kvrrTs r/ zcmdclass..s+ R R R41aA}Q X66 R R Rr1)items)rrrTs ``r/cmdclassr s, S R R R R6<<>> R R RRr1) namespacesfill_package_dirrTrc  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_everseenrt)PEP420PackageFinder) PackageFinderwhererNrc3FK|]}td| VdS)rN) _same_path)r7rsearchs r/r:z find_packages..>s4VVJvay!$<$< <VVVVVVr1r)setuptools.discoveryrrzrrtrrr`curdirrlistrall setdefault _nest_pathfindrkgetrasamefiler+)rrrTkwargsrrrtrrpackagesra package_pathpkgsrs @r/ find_packagesrs0;:::::QQQQQQQQ7MMMMMMM666666$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 Or1parentrac|dvr|ntj||}tj|S)N>rr)r`rarjnormpath)rras r/rrMs;Y&&66BGLL,F,FD 7  D ! !!r1r6cBt|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 rrPintr<hasattrrjmapr5s r/versionrRs %S/*E 2 2E eS ! !! 5* % % !HHSe__--EE5LE Lr1 package_datac>d|vr|d|d<|S)NrVr)r)rs r/canonic_package_datards+ l'++C00 R r1 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|fSrR)rq)r7destrSrTs r/ z&canonic_data_files..us<    D( }Xx001   r1)r<rr)rrTs `r/canonic_data_filesrjsT*d##    (..00   r1 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|(SrR)dictr)r7rrs 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/r0zLazyMappingProxy.__init__s+ 15 r1r2cP|j||_|jSr$)rrrs r/_targetzLazyMappingProxy._targets! ; ,,..DK{r1keyc6||Sr$)r)r-rs r/ __getitem__zLazyMappingProxy.__getitem__s||~~c""r1cDt|Sr$)rrrs r/__len__zLazyMappingProxy.__len__s4<<>>"""r1cDt|Sr$)iterrrs r/rzLazyMappingProxy.__iter__sDLLNN###r1N)rLrMrNrOrr rrr0rr rr"r rrRr1r/rrs  6Xb'"b&/6I-J6666R #r#b#########$(2,$$$$$$r1rr$)NN)r)JrOr%rr`r'rglobr configparserrimportlib.machineryr itertoolsrtypingrrr r r r r rrrrrrtypesrdistutils.errorsr_pathrrwarningsrsetuptools.distrrrdistutils.distr from_iterable chain_iterrPPathLike_Pathrrr rqbytesr}r{ryrxrrrrrrrrrrrrrrrrrrRr1r/r5s&   %%%%%%******                            111111++++++((((((4,,,,,,444444333333   c2; WT]] WTT"""PPPPPPPP8:>sm'/ #YB%UHUO ;<PS$EhuoE(5/EEEEue|, ES04 $#*#*#*'#s(+,#*uo#*#*#*#*LChuo*Zcj11#+GCH,=#>1JO1 5(3- $%1111H04 $ ' ' ''#s(+, 'uo ' ' ' ' '$04 $SS cNS'#s(+,SuoS #x- SSSS15 $ 222tCH~.2uo 2  #Y 2222j"u"E"c"""" 58E#s(O#