Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
discovery.cpython-313.pyc226 linesDownload Raw Back to __pycache__
1�

2��j&S����SrSSKJr SSKrSSKrSSKJrJrJr SSK	J3r4 SSKJr SSKJ
r
 SSKJrJr SSKrS	S5KJr SSKJr SSKJr \(aSS
KJr \R6R8rS%Sjr"SS5r"SS5r "SS\ 5r!"SS\!5r""SS\ 5r#"SS\"5r$"SS\#5r%S&Sjr&"SS5r'S'S jr(S'S!jr)S(S"jr*S)S#jr+S*S$jr,g)+u_Automatic discovery of Python modules and packages (for inclusion in the6distribution) and other config values.7 8For the purposes of this module, the following nomenclature is used:9 10- "src-layout": a directory representing a Python project that contains a "src"11  folder. Everything under the "src" folder is meant to be included in the12  distribution when packaging the project. Example::13 14    .15    ├── tox.ini16    ├── pyproject.toml17    └── src/18        └── mypkg/19            ├── __init__.py20            ├── mymodule.py21            └── my_data_file.txt22 23- "flat-layout": a Python project that does not use "src-layout" but instead24  have a directory under the project root for each package::25 26    .27    ├── tox.ini28    ├── pyproject.toml29    └── mypkg/30        ├── __init__.py31        ├── mymodule.py32        └── my_data_file.txt33 34- "single-module": a project that contains a single Python script direct under35  the project root (no directory used)::36 37    .38    ├── tox.ini39    ├── pyproject.toml40    └── mymodule.py41 42�)�annotationsN)�Iterable�Iterator�Mapping��fnmatchcase)�glob)�Path)�
TYPE_CHECKING�ClassVar�)�StrPath)�log)�convert_path)�Distributionc�\�[RRU5R5$�N)�os�path�basename�isidentifier)rs �ZD:\code\apps\devtools\python\user_packages\Python313\site-packages\setuptools/discovery.py�_valid_namer?s ��
�7�7���D�!�.�.�0�0�c�6�\rSrSrSrSSjrS	SjrS	SjrSrg)43�_Filter�Dzw44Given a list of patterns, create a callable that will be true only if45the input matches at least one of the patterns.46c�8�[RU5Ulgr)�dict�fromkeys�	_patterns)�self�patternss  r�__init__�_Filter.__init__Js�����x�0��rc�B^�[U4SjUR55$)Nc3�<># �UHn[TU5v� M g7frr)�.0�pat�items  �r�	<genexpr>�#_Filter.__call__.<locals>.<genexpr>Ns����D�^�c�;�t�S�)�)�^�s�)�anyr!�r"r*s `r�__call__�_Filter.__call__Ms����D�T�^�^�D�D�Drc��XR;$r�r!r.s  r�__contains__�_Filter.__contains__Ps���~�~�%�%rr2N)r#�str�return�None)r*r5r6�bool)	�__name__�47__module__�__qualname__�__firstlineno__�__doc__r$r/r3�__static_attributes__�rrrrDs���481�E�&rrc��\rSrSr%SrSrS\S'SrS\S'\S49SSjj5r	\SSj5r50Srg	)
�_Finder�Tz@Base class that exposes functionality for module/package findersr?zClassVar[tuple[str, ...]]�ALWAYS_EXCLUDE�DEFAULT_EXCLUDEc	��U=(d URn[UR[[	U55[/URQUQ76[U655$)a�Return a list of all Python items (packages or modules, depending on51the finder implementation) found within directory ``where``.52 53``where`` is the root directory which will be searched.54It should be supplied as a "cross-platform" (i.e. URL-style) path;55it will be converted to the appropriate local path syntax.56 57``exclude`` is a sequence of names to exclude; ``*`` can be used58as a wildcard in the names.59When finding packages, ``foo.*`` will exclude all subpackages of ``foo``60(but not ``foo`` itself).61 62``include`` is a sequence of names to include.63If it's specified, only the named items will be included.64If it's not specified, all found items will be included.65``include`` can contain shell style wildcard patterns just like66``exclude``.67)rD�list�68_find_iterrr5rrC��cls�where�exclude�includes    r�find�_Finder.findZsW��4�0�S�0�0����N�N��S��Z�(��6��+�+�6�g�6���!�
�69�	70rc��[er)�NotImplementedErrorrHs    rrG�_Finder._find_iter}s71��"�!rN)�.r?)�*)rJrrK�
Iterable[str]rLrTr6�	list[str]�rJrrKrrLrr6z
Iterator[str])r9r:r;r<r=rC�__annotations__rD�classmethodrMrGr>r?rrrArATs���J�02�N�-�2�13�O�.�3���!#�!'�	 72�� 73�� 74��	 75�7677� 78�� 79�D�"��"�&-�"�8?�"�	�"��"rrAc�T�\rSrSrSrSr\SSj5r\S	Sj5r	Sr80g)81�
PackageFinder�zA82Generate a list of all Python packages found within a directory83)�ez_setupz*__pycache__c#�# �[R"[U5SS9H�upEnUSSn/USS&UH�n[RR	XH5n	[RRX�5n84U85R
[RRS5nSU;dURX�5(dM�U"U5(aU"U5(dUv� US3U;d	US3U;aM�URU5 M� M� g7f)za86All the packages found in 'where' that pass the 'include' filter, but87not the 'exclude' filter.88T)�followlinksNrRrS�.*)89r�walkr5r�join�relpath�replace�sep�_looks_like_package�append)rIrJrKrL�root�dirs�files�all_dirs�dir�	full_path�rel_path�packages            rrG�PackageFinder._find_iter�s����"$����U���!F��D���A�w�H��D��G����G�G�L�L��3�	��7�7�?�?�9�<��"�*�*�2�7�7�;�;��<���#�:�S�%<�%<�Y�%P�%P���7�#�#�G�G�,<�,<�!�M��Y�a�=�G�+�'��"�~��/H�����C� �' �"G�s�DDc�|�[RR[RRUS55$)z%Does a directory look like a package?�__init__.py)rr�isfilera)r�
_package_names  rre�!PackageFinder._looks_like_package�s&���w�w�~�~�b�g�g�l�l�4��?�@�@rr?NrV)rrrsr5r6r8)r9r:r;r<r=rCrXrG�staticmethodrer>r?rrrZrZ�sW���2�N��!��!�&-�!�8?�!�	�!��!�B�A��ArrZc�(�\rSrSr\SSj5rSrg)�PEP420PackageFinder�c��g)NTr?)�_pathrss  rre�'PEP420PackageFinder._looks_like_package�s��rr?N)rzrrsr5r6r8)r9r:r;r<rurer>r?rrrwrw�s�����rrwc�L�\rSrSrSr\SSj5r\"\5r	Sr90g)�ModuleFinder�zQFind isolated Python modules.91This function will **not** recurse subdirectories.92c#�\# �[[RRUS55H{n[RR	[RRU55upVUR
U5(dMYU"U5(dMhU"U5(aMwUv� M} g7f)Nz*.py)r	rrra�splitextr�_looks_like_module)rIrJrKrL�file�module�_exts       rrG�ModuleFinder._find_iter�st���������e�V�4�5�D��7�7�+�+�B�G�G�,<�,<�T�,B�C�L�F��)�)�&�1�1���v���w�v�����6�s�BB,�B,�#	B,r?NrV)r9r:r;r<r=rXrGrurr�r>r?rrr}r}�sH����93��94�&-�95�8?�96�	�97��98�&�k�2�rr}c�X�\rSrSrSr\"\"S\555r\SSj5r	Sr99g)�FlatLayoutPackageFinder��)#�ci�bin�debian�doc�docs�
documentation�manpages�news�
newsfragments�	changelog�test�tests�	unit_test�100unit_tests�example�examples�scripts�tools�util�utils�python�build�dist�venv�env�requirements�tasks�fabfile�101site_scons�	benchmark�102benchmarks�exercise�	exercises�htmlcov�[._]*c#�.# �UHoUS34v� M
 g7f)r_Nr?)r(�ps  rr+�!FlatLayoutPackageFinder.<genexpr>�s���&G�h��a�S��8�}�h�s�c��URS5nUSR5=(d USRS5nU=(a [SUSS55$)NrRr�-stubsc3�@# �UHoR5v� M g7fr)r)r(�names  rr+�>FlatLayoutPackageFinder._looks_like_package.<locals>.<genexpr>s���(S���):�):�)<�)<��s�r
)�splitr�endswith�all)rz�package_name�names�root_pkg_is_valids    rre�+FlatLayoutPackageFinder._looks_like_package�sU���"�"�3�'��!�!�H�1�1�3�R�u�Q�x�7H�7H��7R�� �S�S�(S��q�r��(S�%S�Srr?N)rzrr�r5r6r8)r9r:r;r<�_EXCLUDE�tuple�103chain_iterrDrurer>r?rrr�r��s8��'�H�R�J�&G�h�&G�G�H�O� ��T��Trr�c��\rSrSrSrSrg)�FlatLayoutModuleFinderi)�setup�conftestr�r�r�r�r��toxfile�noxfile�pavement�dodor�r�z[Ss][Cc]onstruct�	conanfile�manager�r�r�r�r�r?N)r9r:r;r<rDr>r?rrr�r�s���O�4*rr�c��[RU5nU/UVs/sHnSRX45PM sn-$s snf)NrR)rwrMra)�root_pkg�pkg_dir�nested�ns    r�_find_packages_withinr�%s<��
 �
%�
%�g�
.�F��:�&�A�&�Q����8�-�0�&�A�A�A��As�=c���\rSrSrSrSSjrSrSr\SSj5r	\SSj5r104SSSjjrSS	jrSS105jr
SSjrSSjrSS
jrSSjrSSjrSSjrSSjrSSjrSSjrSrg) �ConfigDiscoveryi*z}Fill-in metadata and options that can be automatically derived106(from other metadata/options, the file system or conventions)107c�:�XlSUlSUlSUlg)NF)r��_called�	_disabled�_skip_ext_modules)r"�distributions  rr$�ConfigDiscovery.__init__/s�� �	�������!&��rc��SUlg)z+Internal API to disable automatic discoveryTN)r��r"s r�_disable�ConfigDiscovery._disable5s	����rc��SUlg)a�Internal API to disregard ext_modules.108 109Normally auto-discovery would not be triggered if ``ext_modules`` are set110(this is done for backward compatibility with existing packages relying on111``setup.py`` or ``setup.cfg``). However, ``setuptools`` can call this function112to ignore given ``ext_modules`` and proceed with the auto-discovery if113``packages`` and ``py_modules`` are not given (e.g. when using pyproject.toml114metadata).115TN)r�r�s r�_ignore_ext_modules�#ConfigDiscovery._ignore_ext_modules9s��"&��rc�\�URR=(d [R$r)r��src_rootr�curdirr�s r�	_root_dir�ConfigDiscovery._root_dirEs���y�y�!�!�.�R�Y�Y�.rc�`�URRc0$URR$r)r��package_dirr�s r�_package_dir�ConfigDiscovery._package_dirJs'���9�9� � �(��I��y�y�$�$�$rc��USLa#UR(dUR(agURU5 U(aUR5 SUlg)ayAutomatically discover missing configuration fields116and modifies the given ``distribution`` object in-place.117 118Note that by default this will only have an effect the first time the119``ConfigDiscovery`` object is called.120 121To repeatedly invoke automatic discovery (e.g. when the project122directory changes), please use ``force=True`` (or create a new123``ConfigDiscovery`` instance).124FNT)r�r��_analyse_package_layout�analyse_name)r"�forcer��ignore_ext_moduless    rr/�ConfigDiscovery.__call__Ps?���E�>�t�|�|�t�~�~���$�$�%7�8��������rc�l�U=(d URnURRSL=(d U(+nURRSL=(d[ URRSL=(d< U=(d3 [URS5=(a URR$)zF``True`` if the user has specified some form of package/module listingN�
configuration)r�r��ext_modules�packages�125py_modules�hasattrr�)r"r�r�s   r�_explicitly_specified�%ConfigDiscovery._explicitly_specifiedgs���/�I�4�3I�3I���9�9�0�0�D�8�N�<N�O���I�I���d�*�
(��y�y�#�#�4�/�
(��
(��t�y�y�/�2�(��	�	�'�'�	126rc���URU5(ag[R"S5 UR5=(d' UR	5=(d UR5$)NTzLNo `packages` or `py_modules` configuration, performing automatic discovery.)r�r�debug�_analyse_explicit_layout�_analyse_src_layout�_analyse_flat_layout)r"r�s  rr��'ConfigDiscovery._analyse_package_layouttsa���%�%�&8�9�9���	�	�
#�	127�
�)�)�+�
+��'�'�)�
+��(�(�*�		128rc�^�URR5nURSS5 URmU(dg[R129"SU35 [
U4SjUR555n[U5URl130[R131"SURR35 g)zAThe user can explicitly give a package layout via ``package_dir``�NFz(`explicit-layout` detected -- analysing c3�|># �UH1up[U[RRTU55v� M3 g7fr)r�rrra)r(�pkg�132parent_dir�root_dirs   �rr+�;ConfigDiscovery._analyse_explicit_layout.<locals>.<genexpr>�s3����133�#6���
"�#�r�w�w�|�|�H�j�'I�J�J�#6�s�9<�discovered packages -- T)r��copy�popr�rr�r��itemsrFr�r�)r"r��pkgsr�s   @rr��(ConfigDiscovery._analyse_explicit_layout�s�����'�'�,�,�.������D�!��>�>�����	�	�<�[�M�J�K��134�#.�#4�#4�#6�135�136��"�$�Z��	�	���	�	�+�D�I�I�,>�,>�+?�@�A�rc���URn[RRURURSS55n[RR
U5(dg[R"SU35 URS[RRU55 XRl[RU5URl[ RU5URl[R"SURR35 [R"SURR"35 g)avTry to find all packages or modules under the ``src`` directory137(or anything pointed by ``package_dir[""]``).138 139The "src-layout" is relatively safe for automatic discovery.140We assume that everything within is meant to be included in the141distribution.142 143If ``package_dir[""]`` is not given, but the ``src`` directory exists,144this function will set ``package_dir[""] = "src"``.145r��srcFz#`src-layout` detected -- analysing r�discovered py_modules -- T)r�rrrar��get�isdirrr��146setdefaultrr�r�rwrMr�r}r�)r"r��src_dirs   rr��#ConfigDiscovery._analyse_src_layout�s����'�'���'�'�,�,�t�~�~�{���r�5�/I�J���w�w�}�}�W�%�%���	�	�7��y�A�B����r�2�7�7�#3�#3�G�#<�=� +�	�	��0�5�5�g�>��	�	��+�0�0��9��	�	���	�	�+�D�I�I�,>�,>�+?�@�A��	�	�-�d�i�i�.B�.B�-C�D�E�rc��[R"SUR35 UR5=(d UR	5$)a�Try to find all packages and modules under the project root.147 148Since the ``flat-layout`` is more dangerous in terms of accidentally including149extra files/directories, this function is more conservative and will raise an150error if multiple packages or modules are found.151 152This assumes that multi-package dists are uncommon and refuse to support that153use case in order to be able to prevent unintended errors.154z$`flat-layout` detected -- analysing )rr�r��_analyse_flat_packages�_analyse_flat_modulesr�s rr��$ConfigDiscovery._analyse_flat_layout�s:��	�	�	�8����8H�I�J��*�*�,�L��0J�0J�0L�Lrc�B�[RUR5URl[[
URR55n[R"SURR35 URUS5 [U5$)Nrr�)r�rMr�r�r��remove_nested_packages�remove_stubsrr��_ensure_no_accidental_inclusionr8)r"�	top_levels  rr�&ConfigDiscovery._analyse_flat_packages�so��4�9�9�$�.�.�I��	�	��*�<��	�	�8J�8J�+K�L�	��	�	�+�D�I�I�,>�,>�+?�@�A��,�,�Y�155�C��I��rc�B�[RUR5URl[156R"SURR35 URURRS5 [URR5$)Nr	�modules)	r�rMr�r�r�rr�rr8r�s rr�%ConfigDiscovery._analyse_flat_modules�sk��5�:�:�4�>�>�J��	�	���	�	�-�d�i�i�.B�.B�-C�D�E��,�,�T�Y�Y�-A�-A�9�M��D�I�I�(�(�)�)rc�n�[U5S:�a&SSKJn SSKJn SUSUSUS3nU"U"U55eg)	Nr
r)�cleandoc)�PackageDiscoveryErrorzMultiple top-level z discovered in a flat-layout: z�.157 158            To avoid accidental inclusion of unwanted files or directories,159            setuptools will not proceed with this build.160 161            If you are trying to create a single distribution with multiple a�162            on purpose, you should not rely on automatic discovery.163            Instead, consider the following options:164 165            1. set up custom discovery (`find` directive with `include` or `exclude`)166            2. use a `src-layout`167            3. explicitly set `py_modules` or `packages` with a list of names168 169            To find more information, look for "package discovery" on setuptools docs.170            )�len�inspectr�setuptools.errorsr)r"�detected�kindrr�msgs      rr�/ConfigDiscovery._ensure_no_accidental_inclusion�sU���x�=�1��(�?�)�$��/M�h�Z�XM�171NR�F�	S
��C�(���
�6�6�)rc�D�URRR(dURR(ag[R"S5 UR5=(d UR
5nU(aXRRlgg)z�The packages/modules are the essential contribution of the author.172Therefore the name of the distribution can be derived from them.173Nz7No `name` configuration, performing automatic discovery)r��metadatar�rr��#_find_name_single_package_or_module�_find_name_from_packages)r"r�s  rr��ConfigDiscovery.analyse_name�so���9�9���"�"�d�i�i�n�n���	�	�K�L�
�4�4�6�
/��,�,�.�	
��&*�I�I���#�rc���SH^n[URUS5=(d /nU(dM,[U5S:XdM=[R"SUS35 USs $ g)zExactly one module or package)r�r�Nr
z&Single module/package detected, name: r)�getattrr�rrr�)r"�fieldrs   rr(�3ConfigDiscovery._find_name_single_package_or_module�sX��/�E��D�I�I�u�d�3�9�r�E��u��U��q���	�	�B�5��8�*�M�N��Q�x��	0�rc�l�URR(dg[[URR[S95nURR174=(d 0n[
XUR5nU(a[R"SU35 U$[R"S5 g)z<Try to find the root package that is not a PEP 420 namespaceN��keyz&Common parent package detected, name: z7No parent package detected, impossible to derive `name`)r�r�r�sortedrr��find_parent_packager�rr��warn)r"r�r��175parent_pkgs    rr)�(ConfigDiscovery._find_name_from_packages�s~���y�y�!�!����t�y�y�'9�'9�s� C�D���i�i�+�+�1�r��(�����O�176���I�I�>�z�l�K�L������J�K�r)r�r�r�r�N)r�rr6r7)r6r)r6�dict[str, str])FTF)r�r8r�r8r�r8r6r7)r�r8r6r8)r6r8)r"rUr#r5)r6r7)r6�177str | None)r9r:r;r<r=r$r�r��propertyr�r�r/r�r�r�r�r�rrrr�r(r)r>r?rrr�r�*s����'��178&��/��/��%��%�RW����)-��JN��	
��.179�180�$�$�2M��*�7�.+�"�rr�c��^�[U[S9nUSSn[U5n[[U55H8unm[	U4SjU55(dM"URX4-181S-1825 M: U$)z�Remove nested packages from a list of packages.183 184>>> remove_nested_packages(["a", "a.b1", "a.b2", "a.b1.c1"])185['a']186>>> remove_nested_packages(["a", "b", "c.d", "c.d.e.f", "g.h", "a.a1"])187['a', 'b', 'c.d', 'g.h']188r0Nc3�L># �UHnTRUS35v� M g7f�rRN��189startswith)r(�otherr�s  �rr+�)remove_nested_packages.<locals>.<genexpr>s#����C���t���%���{�+�+��s�!$r
)r2r�	enumerate�reversedr-r)r�rr�size�ir�s     @rrrse����(��$�D��Q��I��t�9�D��X�d�^�,���4��C��C�C�C��M�M�$�(�Q�,�'�-��rc��UVs/sH.oRS5SRS5(aM,UPM0 sn$s snf)z�Remove type stubs (:pep:`561`) from a list of packages.190 191>>> remove_stubs(["a", "a.b", "a-stubs", "a-stubs.b.c", "b", "c-stubs"])192['a', 'a.b', 'b']193rRrr�)r�r�)r�r�s  rrr s4��$�P�8�C�9�9�S�>�!�+<�+E�+E�h�+O�C�8�P�P��Ps�+=�=c�n^�[U[S9n/n[U5H8unm[U4SjXS-S55(d OUR	T5 M: UHWm[TX5n[RRUS5n[RRU5(dMUTs $ g)z0Find the parent package that is not a namespace.r0c3�J># �UHoRTS35v� M g7fr<r=)r(r�r�s  �rr+�&find_parent_package.<locals>.<genexpr>0s#����G�5F��<�<�4�&��194�+�+�5F�s� #r
Nrq)195r2rrAr�rf�find_package_pathrrrarr)r�r�r��common_ancestorsrD�pkg_path�initr�s       @rr3r3)s�����h�C�(�H����X�&���4��G�X�!�e�g�5F�G�G�G�196
�����%�'�!��$�T�;�A���w�w�|�|�H�m�4��
�7�7�>�>�$����K�	!�rc�z�URS5n[[U5SS5HEnSRUSU5nXQ;dMXn[R197R"X&/X4SQ76s $ UR
S5=(d Sn[R198R"U/URS5QUQ76$)a_Given a package name, return the path where it should be found on199disk, considering the ``package_dir`` option.200 201>>> path = find_package_path("my.pkg", {"": "root/is/nested"}, ".")202>>> path.replace(os.sep, "/")203'./root/is/nested/my/pkg'204 205>>> path = find_package_path("my.pkg", {"my": "root/is/nested"}, ".")206>>> path.replace(os.sep, "/")207'./root/is/nested/pkg'208 209>>> path = find_package_path("my.pkg", {"my.pkg": "root/is/nested"}, ".")210>>> path.replace(os.sep, "/")211'./root/is/nested'212 213>>> path = find_package_path("other.pkg", {"my.pkg": "root/is/nested"}, ".")214>>> path.replace(os.sep, "/")215'./other/pkg'216rRr�����Nr��/)r��rangerrarrr217)r�r�r��partsrD�partial_name�parents       rrIrIAs���,
�J�J�s�O�E�
�3�u�:�q�"�
%���x�x��b�q�	�*���&� �.�F��7�7�<�<��=�5��9�=�=�&��_�_�R�
 �
&�B�F�
�7�7�<�<��=�6�<�<��#4�=�u�=�=rc218��[U5n[U5RnUVs0sH'oDSR/UQUR	S5Q5_M) sn$s snf)NrOrR)rr219rQrar�)r��package_path�parent_pkgs�prefixr�s     r�construct_package_dirrXcsS��(��2�K�
�,�
�
%�
%�F�AL�M��#����4�F�4�S�Y�Y�s�^�4�5�5��M�M��Ms�.A)rrr6r8)r�r5r�rr6rU)r�rUr6rU)r�rUr��Mapping[str, str]r�rr6r8)r�r5r�rYr�rr6r5)r�rUrUrr6r7)-r=�220__future__r�	itertoolsr�collections.abcrrr�fnmatchrr	�pathlibr221�typingrr�_distutils_hack.override�_distutils_hackrzr�	distutilsr�distutils.utilr�222setuptoolsr�chain�
from_iterabler�rrrArZrwr}r�r�r�r�rrr3rIrXr?rr�<module>rgs��%�N#��	�7�7����*����'��'�
�_�_�
*�
*�223�1�224
&�
&� -"�-"�`,A�G�,A�^�-��3�7�3�22T�1�2T�j*�\�*�<B�225a�a�H�$Q����&7��CJ����0>�226
�>�-�>�9@�>��>�DNr
codekingpro/portable-devtools · Team Ai