_i@ .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 jVZ,ee-ej\fZ/edZ0eddZ1GddZ2 d@dee-dee/dee-fdZ3d@dee-e4ee/fde-fdZ5dee/dee/fdZ6dee4e/fde-fdZ7de/de-fd Z8 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-fd0Z?d1e/d2e/de-fd3Z@d4eeeee-eAfe-fde-fd5ZBd6eCdeCfd7ZD d@d8eeEeCfdee/deee-ee-ffd9ZFdBd:e-dee-eCffd;ZGGd<d=ZHGd>d?ee0e1fZIy)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)SetuptoolsWarning) Distribution)ConfigDiscovery)DistributionMetadata_K_VT) covariantcjeZdZdZdedefdZdeee je jffdZ dZ y) StaticModulez>Proxy to a module object that avoids executing arbitrary code.namespecctjtj|jj }t |jt|` yN) astparsepathlibrorigin read_bytesvarsupdatelocalsself)r-r!r"modules /builddir/build/BUILDROOT/alt-python312-setuptools-69.0.2-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/setuptools/config/expand.py__init__zStaticModule.__init__As?7<< 4??AB T &(# Ireturnc#<K|jjD]|ttjrfdj DEd{;ttj sVjscjjf~y7Jw)Nc3:K|]}|jfywr$value).0target statements r/ z1StaticModule._find_assignments..IsVDU&VY__5DUs) r.body isinstancer%Assigntargets AnnAssignr6r8)r-r9s @r/_find_assignmentszStaticModule._find_assignmentsFsi))I)SZZ0VIDUDUVVVIs}}5)// ''99 *VsA BBB0 B=Bc tfd|jDS#t$r }t|jd|d}~wwxYw)zHAttempt to load an attribute "statically", via :func:`ast.literal_eval`.c3K|]E\}}t|tjr&|jk(rtj|Gywr$)r<r%Nameid literal_eval)r7r8r6attrs r/r:z+StaticModule.__getattr__..PsA%=MFEfchh/FII4E  '%=sA Az has no attribute N)nextr@ ExceptionAttributeErrorr!)r-rFes ` r/ __getattr__zStaticModule.__getattr__Ms] P%)%;%;%=   P DII;.@!GHa O Ps!% AA  AN) __name__ __module__ __qualname____doc__strrr0r rr%ASTr@rKr1r/r r >sAHS  :8E#''3772B,C#D: Pr1r patternsroot_dirr2c hd}g}xstj|D]tfd|Drltjj tjj }|j tfdt|dDtjjjtjd}|j||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|]}|v ywr$rR)r7charr6s r/r:z glob_relative..hs9tu}sc3K|]B}tjj|jtjdDyw)/N)ospathrelpathreplacesepr7rarTs r/r:z glob_relative..ls9 @GGOOD(3;;BFFCH @sAA T) recursiver_) r`getcwdanyraabspathjoinextendsortedrrbrcrdappend)rSrTglob_charactersexpanded_values glob_pathrar6s ` @r/ glob_relativerqYs5OO&299;H 99 9 Xu(EFI  " " %i4 @ 77??5(3;;BFFCHD  " "4 (" r1 filepathscddlm}tjj xstj fd||D}dj fdt|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_iterablec3^K|]$}tjj|&ywr$)r`rarjres r/r:zread_files..s#V;U4"'',,x.;Us*- c3LK|]}t|r t|ywr$) _assert_local _read_fileres r/r:zread_files..s(6D x ( 46s!$) setuptools.extern.more_itertoolsrtr`rarirgrj_filter_existing_files)rrrTrt _filepathss ` r/ read_filesr}zsXAwwx6299;7HV?9;UVJ 99*:6 r1c#K|D]?}tjj|r|'tjd|dAyw)NzFile z cannot be found)r`raisfileremit)rrras r/r{r{s= 77>>$ J  " "U4(2B#C D sAAfilepathcht|d5}|jcdddS#1swYyxYw)Nzutf-8)encoding)openread)rfs r/ryrys# h )Qvvx * ) )s(1cttjj|ttjj|jvrd|d|d}t |y)NzCannot access z (or anything outside )T)rr`rariparentsr)rrTmsgs r/rxrxsW BGGOOH %&d277??83L.M.U.UUxl*@ AN"3'' r1 attr_desc package_dirct|xstj}|jjd}|j }dj |}|xsd}t |||\}}}t||} tt|||S#t$rt||} 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,&299;H"((-J I((:&K+K&2; X&V#L$ k4 (D*|K6 BB *D+.vy))*s=B!B76B7r module_pathctjj||}|xstjj|}| t ||Sr$) importlibutilspec_from_file_location find_specModuleNotFoundError)rrr"s r/rrsF >> 1 1+{ KD  89>>++K8D |!+.. Kr1r"ct|d|}|tjvrtj|Stjj |}|tj|<|j j||S)NrL)rsysmodulesrrmodule_from_specloader exec_module)r"rr!r.s r/rrsd 4[ 1D s{{{{4  ^^ , ,T 2FCKKKKF# Mr1cb|}|jd}|r|d|vrk||d}|jdd}t|dkDr)tjj ||d}|d}n|}dj |g|dd}n'd|vr#tjj ||d}tjj |g|jd}t |dtjj |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.*c3`K|]&}tjj|s#|(ywr$)r`rar)r7xs r/r:z_find_module..s C:a1B:s$..) rrsplitlenr`rarjrrrG) rrrT parent_path module_parts custom_pathparts parent_module path_start candidatesrs r/rrs0K$$S)L ?k )%l1o6K&&sA.E5zA~ ggll8U1X> %a + ((M#EL4D#EFK ; '',,xRAKkCK,=,=c,BCJ  R>41aA}Q X6 6> RR Rs0) namespacesfill_package_dirrTrc P ddlm}ddlm}m}|rddlm}nddlm}|xstj}|jddg}g} |in|}t||| t dk(r+t fd d|fDr|jd d D]} t|| } |j| fi|} | j!| | s6|j#d | k(rKtj$j'| |rl|j)|| | | 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) PackageFinderwhererrc3>K|]}td| yw)rN) _same_path)r7rsearchs r/r:z find_packages..>s VoJvay!$< rr)r`rarjnormpath)rras r/rrMs4Y&6BGGLL,FD 77  D !!r1r6ct|r|}ttttt f|}t |ts2t|dr!djtt|}|Sd|z}|S)z`When getting the version directly from an attribute, it should be normalised to string. __iter__rz%s) callablerr rrPintr<hasattrrjmapr5s r/versionrRsj %S/*E 2E eS ! 5* %HHSe_-E L5LE Lr1 package_datac6d|vr|jd|d<|S)NrVr)r)rs r/canonic_package_datards% l'++C0 R r1 data_filesc t|tr|S|jDcgc]\}}|t||fc}}Scc}}w)zFor compatibility with ``setup.py``, ``data_files`` should be a list of pairs instead of a dict. This function also expands glob patterns. )r<rrrq)rrTdestrSs r/canonic_data_filesrjsT*d#)..0 0ND( }Xx010  sAtextc tdd}t|_|j|||j Dcic]\}}|t |j !}}}|j |jd|Scc}}w)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)rrP optionxform read_stringrdictrr)r text_sourceparserrrgroupss r/ entry_pointsr{ss$6 BFF t[)-3\\^ <^TQaaggi ^F < JJv%%t, M=s$Bc`eZdZdZd dZdZdZdZdee e ffdZ e dee e ffdZ y ) EnsurePackagesDiscoveredaSome 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 ||_d|_y)NF)_dist_called)r- distributions r/r0z!EnsurePackagesDiscovered.__init__s!  r1cd|js$d|_|jjdyy)zBTrigger the automatic package discovery, if it is still necessary.TF)r!N)rr set_defaultsr-s r/__call__z!EnsurePackagesDiscovered.__call__s*||DL JJ # # # /r1c|Sr$rRrs r/ __enter__z"EnsurePackagesDiscovered.__enter__s r1cf|jr%|jjjyyr$)rrr analyse_name)r- _exc_type _exc_value _tracebacks r/__exit__z!EnsurePackagesDiscovered.__exit__s$ << JJ # # 0 0 2 r1r2cH||jj}|iS|Sr$)rr)r-pkg_dirs r/_get_package_dirz)EnsurePackagesDiscovered._get_package_dirs% **((_r1'1r1c,t|jS)zCProxy to ``package_dir`` that may trigger auto-discovery when used.)LazyMappingProxyr rs r/rz$EnsurePackagesDiscovered.package_dirs  5 566r1N)rr) rLrMrNrOr0rrr r rPr propertyrrRr1r/rrsT0 32'#s("32 7WS#X.77r1rcteZdZdZdegeeefffdZdeeeffdZ dedefdZ de fdZ de efd Zy ) raMapping 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' obtain_mapping_valuec ||_d|_yr$)_obtain_value)r-rs r/r0zLazyMappingProxy.__init__s+ 15 r1r2c\|j|j|_|jSr$)rrrs r/_targetzLazyMappingProxy._targets# ;; ,,.DK{{r1keyc(|j|Sr$)r)r-rs r/ __getitem__zLazyMappingProxy.__getitem__s||~c""r1c4t|jSr$)rrrs r/__len__zLazyMappingProxy.__len__s4<<>""r1c4t|jSr$)iterrrs r/rzLazyMappingProxy.__iter__sDLLN##r1N)rLrMrNrOrr rrr0rrrrr rrRr1r/rrsh 6Xb'"b&/6I-J6R #r#b###$(2,$r1rr$)NN)z entry-points)JrOr%rr`r'rglobr configparserrimportlib.machineryr itertoolsrtypingrrr r r r r rrrrrrtypesrdistutils.errorsr_pathrrwarningsrsetuptools.distrrrdistutils.distr from_iterable chain_iterrPPathLike_Pathrrr rqbytesr}r{ryrxrrrrrrrrrrrrrrrrrrRr1r/r/s&   %*    1+(,43   c2;; T] TT"PP8:>sm'/ #YB%UHUO ;<PS$EhuoE(5/Eue|, ES04 $#*#*'#s(+,#*uo#*LChuo*Zcj11#+GCH,=#>1JO1 5(3- $%1H04 $ ' ''#s(+, 'uo ' '$04 $S cNS'#s(+,SuoS #x- S15 $ 2tCH~.2uo 2  #Y 2j"u"E"c" 58E#s(O#