efR dZddlZddlZddlmZddlmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZddlZddlmZddlmZeeejfZe eZejjZe rdd lm Z d ed e!fd Z"Gd dZ#GddZ$Gdde$Z%Gdde%Z&Gdde$Z'Gdde&Z(Gdde'Z)deded e efdZ*GddZ+d e ed e efd!Z,d e ed e efd"Z-d e ed#eeefd$ed eefd%Z.d&ed#eeefd$ed efd'Z/d e ed(ed e eeffd)Z0dS)*u_Automatic discovery of Python modules and packages (for inclusion in the distribution) and other config values. For the purposes of this module, the following nomenclature is used: - "src-layout": a directory representing a Python project that contains a "src" folder. Everything under the "src" folder is meant to be included in the distribution when packaging the project. Example:: . ├── tox.ini ├── pyproject.toml └── src/ └── mypkg/ ├── __init__.py ├── mymodule.py └── my_data_file.txt - "flat-layout": a Python project that does not use "src-layout" but instead have a directory under the project root for each package:: . ├── tox.ini ├── pyproject.toml └── mypkg/ ├── __init__.py ├── mymodule.py └── my_data_file.txt - "single-module": a project that contains a single Python script direct under the project root (no directory used):: . ├── tox.ini ├── pyproject.toml └── mymodule.py N fnmatchcase)glob)Path) TYPE_CHECKINGDictIterableIteratorListMappingOptionalTupleUnion)log) convert_path) Distributionpathreturncdtj|SN)osrbasename isidentifier)rs t/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/discovery.py _valid_namerGs$ 7  D ! ! . . 0 00c>eZdZdZdefdZdedefdZdedefdZdS) _Filterz Given a list of patterns, create a callable that will be true only if the input matches at least one of the patterns. patternscDt||_dSr)dictfromkeys _patterns)selfrs r__init__z_Filter.__init__Rsx00ritemrcDtfd|jDS)Nc38K|]}t|VdSrr).0patr&s r z#_Filter.__call__..Vs-DDc;tS))DDDDDDr)anyr#r$r&s `r__call__z_Filter.__call__Us(DDDDT^DDDDDDrc||jvSr)r#r-s r __contains__z_Filter.__contains__Xst~%%rN) __name__ __module__ __qualname____doc__strr%boolr.r0rrrrLs 1#1111ESETEEEE&&&&&&&&rrc eZdZUdZdZeedfed<dZeedfed<e dde d e ed e ed e efd Z e de d ed ed efd ZdS)_Finderz@Base class that exposes functionality for module/package findersr7.ALWAYS_EXCLUDEDEFAULT_EXCLUDE.*whereexcludeincluderc |p|j}t|tt |t g|j|Rt |S)aFReturn a list of all Python items (packages or modules, depending on the finder implementation) found within directory 'where'. 'where' is the root directory which will be searched. It should be supplied as a "cross-platform" (i.e. URL-style) path; it will be converted to the appropriate local path syntax. 'exclude' is a sequence of names to exclude; '*' can be used as a wildcard in the names. When finding packages, 'foo.*' will exclude all subpackages of 'foo' (but not 'foo' itself). 'include' is a sequence of names to include. If it's specified, only the named items will be included. If it's not specified, all found items will be included. 'include' can contain shell style wildcard patterns just like 'exclude'. )r;list _find_iterrr5rr:clsr?r@rAs rfindz _Finder.findbsf40S0 NNSZZ((6+6g666!     rctr)NotImplementedErrorrEs rrDz_Finder._find_iters!!rN)r<r7r=)r1r2r3r4r:rr5__annotations__r; classmethod_Pathr r rGrStrIterrDr7rrr9r9\sJJ&(NE#s(O(((')OU38_)))!#!'     #  #  c    [  D"u"w""W"""["""rr9c beZdZdZdZededededefdZ e ded e de fd Z d S) PackageFinderzI Generate a list of all Python packages found within a directory )ez_setupz *__pycache__r?r@rArc#Ktjt|dD]\}}}|dd}g|dd<|D]}tj||} tj| |} | tjjd} d|vs|| | s|| r|| s| V| d|vs| d|vr| |dS)zy All the packages found in 'where' that pass the 'include' filter, but not the 'exclude' filter. T) followlinksNr<r>.*) rwalkr5rjoinrelpathreplacesep_looks_like_packageappend) rFr?r@rArootdirsfilesall_dirsdir full_pathrel_pathpackages rrDzPackageFinder._find_iters; "$U!F!F!F ! ! D$AAAwHDG ! !GLLs33 7??9e<<"**27;<<#::S%<%A%AAAAA\AAArrOc2eZdZedededefdZdS)PEP420PackageFinder_pathrcrcdS)NTr7)rjrcs rrYz'PEP420PackageFinder._looks_like_packagestrN)r1r2r3rgrLr5r6rYr7rrririsG5\rric PeZdZdZededededefdZe e Z dS) ModuleFinderzYFind isolated Python modules. This function will **not** recurse subdirectories. r?r@rArc#HKttj|dD]q}tjtj|\}}||sW||r||s|VrdS)Nz*.py)rrrrUsplitextr_looks_like_module)rFr?r@rAfilemodule_exts rrDzModuleFinder._find_iterseV4455  D7++BG,<,s,&G&Ga888}&G&G&G&G&G&Grrj package_namerc|d}|dp|dd}|o td|ddDS)Nr<r-stubsc3>K|]}|VdSr)r)r)names rr+z>FlatLayoutPackageFinder._looks_like_package..s.(S(S):):)<)<(S(S(S(S(S(Sr)splitrendswithall)rjrnamesroot_pkg_is_valids rrYz+FlatLayoutPackageFinder._looks_like_packagesl""3''!!H1133RuQx7H7H7R7R SS(S(Sqrr(S(S(S%S%SSrN) r1r2r3_EXCLUDEtuple chain_iterr;rgrLr5r6rYr7rrrurus'HReJJ&G&Gh&G&G&GGGHHO T5TTTTT\TTTrruceZdZdZdS)FlatLayoutModuleFinder)setupconftestrrrrrtoxfilenoxfilepavementdodorrz[Ss][Cc]onstruct conanfilemanagerrrrrN)r1r2r3r;r7rrrr sO4*)rrroot_pkgpkg_dirc\t|}gfd|DzS)Nc>g|]}d|fS)r<)rU)r)nrs r z)_find_packages_within..)s)AAAQ8Q-00AAAr)rirG)rrnesteds` r_find_packages_withinr's8 % %g . .F :AAAA&AAA AArc$eZdZdZddZdZdZedefdZ ede e e ffd Z dd Z d edefdZd edefdZdefdZdefdZdefdZdefdZdefdZdee de fdZdZdee fdZdee fdZdS)ConfigDiscoveryzFill-in metadata and options that can be automatically derived (from other metadata/options, the file system or conventions) distributionrc>||_d|_d|_d|_dS)NF)r_called _disabled_skip_ext_modules)r$rs rr%zConfigDiscovery.__init__1s%   !&rcd|_dS)z+Internal API to disable automatic discoveryTN)rr$s r_disablezConfigDiscovery._disable7s rcd|_dS)aInternal API to disregard ext_modules. Normally auto-discovery would not be triggered if ``ext_modules`` are set (this is done for backward compatibility with existing packages relying on ``setup.py`` or ``setup.cfg``). However, ``setuptools`` can call this function to ignore given ``ext_modules`` and proceed with the auto-discovery if ``packages`` and ``py_modules`` are not given (e.g. when using pyproject.toml metadata). TN)rrs r_ignore_ext_modulesz#ConfigDiscovery._ignore_ext_modules;s"&rrc2|jjp tjSr)rsrc_rootrcurdirrs r _root_dirzConfigDiscovery._root_dirGsy!.RY.rc6|jjiS|jjSr)r package_dirrs r _package_dirzConfigDiscovery._package_dirLs 9 (Iy$$rFTc|dur|js|jrdS|||r|d|_dS)aAutomatically discover missing configuration fields and modifies the given ``distribution`` object in-place. Note that by default this will only have an effect the first time the ``ConfigDiscovery`` object is called. To repeatedly invoke automatic discovery (e.g. when the project directory changes), please use ``force=True`` (or create a new ``ConfigDiscovery`` instance). FNT)rr_analyse_package_layout analyse_name)r$forcerignore_ext_moduless rr.zConfigDiscovery.__call__RsX E>>t|>t~> F $$%7888        rrc|p|j}|jjdup| }|jjdup0|jjdup"|p t |jdo |jjS)zF``True`` if the user has specified some form of package/module listingN configuration)rr ext_modulespackages py_moduleshasattrr)r$rrs r_explicitly_specifiedz%ConfigDiscovery._explicitly_specifiedgsw/I43I90D8N.sU  Z "#rw||Hj'I'I J J      rdiscovered packages -- T) rcopypoprrrritemsrCrr)r$rpkgsrs @rrz(ConfigDiscovery._analyse_explicit_layouts',,.. D!!!> 5 J[JJKKK    #.#4#4#6#6     "$ZZ  @DI,>@@AAAtrc|j}tj|j|dd}tj|sdStjd|| dtj |||j _ t||j _t ||j _tjd|j jtjd|j jdS)aTry to find all packages or modules under the ``src`` directory (or anything pointed by ``package_dir[""]``). The "src-layout" is relatively safe for automatic discovery. We assume that everything within is meant to be included in the distribution. If ``package_dir[""]`` is not given, but the ``src`` directory exists, this function will set ``package_dir[""] = "src"``. rsrcFz#`src-layout` detected -- analysing rdiscovered py_modules -- T)rrrrUrgetisdirrr setdefaultrrrrirGrrmr)r$rsrc_dirs rrz#ConfigDiscovery._analyse_src_layouts' ',,t~{r5/I/IJJw}}W%% 5 AAABBBr27#3#3G#<#<=== + 055g>> +0099  @DI,>@@AAA Ddi.BDDEEEtrctjd|j|p|S)aTry to find all packages and modules under the project root. Since the ``flat-layout`` is more dangerous in terms of accidentally including extra files/directories, this function is more conservative and will raise an error if multiple packages or modules are found. This assumes that multi-package dists are uncommon and refuse to support that use case in order to be able to prevent unintended errors. z$`flat-layout` detected -- analysing )rrr_analyse_flat_packages_analyse_flat_modulesrs rrz$ConfigDiscovery._analyse_flat_layoutsB IIIJJJ**,,L0J0J0L0LLrc,t|j|j_t t |jj}tjd|jj| |dt|S)Nrr) rurGrrrremove_nested_packages remove_stubsrr_ensure_no_accidental_inclusionr6)r$ top_levels rrz&ConfigDiscovery._analyse_flat_packagessv499$.II *< 8J+K+KLL  @DI,>@@AAA ,,Y CCCIrct|j|j_t jd|jj||jjdt|jjS)Nrmodules) rrGrrrrrrr6rs rrz%ConfigDiscovery._analyse_flat_modulessh5::4>JJ  Ddi.BDDEEE ,,TY-A9MMMDI()))rdetectedkindct|dkr,ddlm}ddlm}d|d|d|d}|||dS) Nrr)cleandoc)PackageDiscoveryErrorzMultiple top-level z discovered in a flat-layout: z. To avoid accidental inclusion of unwanted files or directories, setuptools will not proceed with this build. If you are trying to create a single distribution with multiple a on purpose, you should not rely on automatic discovery. Instead, consider the following options: 1. set up custom discovery (`find` directive with `include` or `exclude`) 2. use a `src-layout` 3. explicitly set `py_modules` or `packages` with a list of names To find more information, look for "package discovery" on setuptools docs. )leninspectrsetuptools.errorsr)r$rrrrmsgs rrz/ConfigDiscovery._ensure_no_accidental_inclusions x==1   ( ( ( ( ( ( ? ? ? ? ? ?$h NR C(' 66 6)  rc|jjjs |jjrdStjd|p|}|r||jj_dSdS)zThe packages/modules are the essential contribution of the author. Therefore the name of the distribution can be derived from them. Nz7No `name` configuration, performing automatic discovery)rmetadatarrr#_find_name_single_package_or_module_find_name_from_packages)r$rs rrzConfigDiscovery.analyse_names 9  " din 4 KLLL  4 4 6 6 /,,..   +&*DI  # # # + +rcdD]V}t|j|dpg}|r:t|dkr'tjd|d|dcSWdS)zExactly one module or package)rrNrz&Single module/package detected, name: r)getattrrrrr)r$fieldrs rrz3ConfigDiscovery._find_name_single_package_or_moduleso/  EDIud339rE Uq M58MMNNNQxtrc"|jjsdStt|jjt}|jjpi}t |||j}|rtj d||Stj ddS)z>> remove_nested_packages(["a", "a.b1", "a.b2", "a.b1.c1"]) ['a'] >>> remove_nested_packages(["a", "b", "c.d", "c.d.e.f", "g.h", "a.a1"]) ['a', 'b', 'c.d', 'g.h'] r Nc3HK|]}|dVdSr<N startswith)r)otherrs rr+z)remove_nested_packages..s5CCt%{{{++CCCCCCrr)rr enumeratereversedr,r)rrrsizeirs @rrrs ( $ $ $DQQQI t99DXd^^,,((4 CCCCCCC C C ( MM$(Q, ' ' ' rcd|DS)zRemove type stubs (:pep:`561`) from a list of packages. >>> remove_stubs(["a", "a.b", "a-stubs", "a-stubs.b.c", "b", "c-stubs"]) ['a', 'a.b', 'b'] cng|]2}|ddd0|3S)r<rr)rr)r)rs rrz remove_stubs..&s: P P PC399S>>!+<+E+Eh+O+O PC P P Prr7)rs rrr s Q P8 P P PPrrrct|t}g}t|D]B\}tfd||dzdDsn|C|D]Vt ||}t j|d}t j |rcSWdS)z0Find the parent package that is not a namespace.r c3HK|]}|dVdSrr)r)rrs rr+z&find_parent_package..0s5GG1<<4 ++GGGGGGrrNre) rrrrrZfind_package_pathrrrUrf)rrrcommon_ancestorsrpkg_pathinitrs @rrr)shC(((HX&&&&4GGGGXa!egg5FGGGGG  E%%%% $T;AAw||Hm44 7>>$   KKK  4rrc|d}tt|ddD]M}d|d|}||vr*||}t jj||g||dRcSN|dpd}t jj|g|d|RS)aGiven a package name, return the path where it should be found on disk, considering the ``package_dir`` option. >>> path = find_package_path("my.pkg", {"": "root/is/nested"}, ".") >>> path.replace(os.sep, "/") './root/is/nested/my/pkg' >>> path = find_package_path("my.pkg", {"my": "root/is/nested"}, ".") >>> path.replace(os.sep, "/") './root/is/nested/pkg' >>> path = find_package_path("my.pkg", {"my.pkg": "root/is/nested"}, ".") >>> path.replace(os.sep, "/") './root/is/nested' >>> path = find_package_path("other.pkg", {"my.pkg": "root/is/nested"}, ".") >>> path.replace(os.sep, "/") './other/pkg' r<rNr/)rrangerrUrrr)rrrpartsr partial_nameparents rr!r!As, JJsOOE 3u::q" % %>>xxbqb ** ; & & .F7<&=59=== = = = '__R &BF 7< =6<<#4#4 =u = = ==r package_pathcft|}t|jfd|DS)Nc ji|]/}|dg|d0S)r'r<)rUr)r)rprefixs r z)construct_package_dir..fs< M M M#C4F4SYYs^^455 M M Mr)rrr))rr, parent_pkgsr/s @rconstruct_package_dirr2cs:(22K ,   %F M M M M M M MMr)1r4 itertoolsrfnmatchrrpathlibrtypingrrr r r r r rr_distutils_hack.override_distutils_hack distutilsrdistutils.utilrr5PathLikerLrMchain from_iterabler setuptoolsrr6rrr9rOrirmrurrrrrrr!r2r7rrr?s%%N                        '''''' c2; 3- _ * (''''''1e11111 & & & & & & & & +"+"+"+"+"+"+"+"\*A*A*A*A*AG*A*A*AZ- 333337333.2T2T2T2T2T12T2T2Tj*****\***<BCB%BDIBBBB ________DT#Y49$Q49QcQQQQ3i&-c3h&7CH c]0> >#CH->9>>>>>>DNDINUNtCQTH~NNNNNNr