� ,�Re?Q� ���dZddlZddlZddlmZddlmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZmZddlZddlmZddlmZeeejfZe egefZe eZejj Z!e rdd l"m#Z#d ed efd �Z$Gd �d��Z%Gd�de%��Z&Gd�de&��Z'Gd�de%��Z(Gd�de'��Z)Gd�de(��Z*deded eefd�Z+Gd�d��Z,deed eefd�Z-deed eefd �Z.deed!eeefd"ed eefd#�Z/d$ed!eeefd"ed efd%�Z0deed&ed e eeffd'�Z1dS)(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_CHECKING�Callable�Dict�Iterable�Iterator�List�Mapping�Optional�Tuple�Union)�log)� convert_path)� Distribution�path�returnc�d�tj�|�����S�N)�osr�basename� isidentifier)rs ��/builddir/build/BUILDROOT/alt-python311-setuptools-65.6.3-2.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/setuptools/discovery.py� _valid_namerIs$�� �7� � �D� !� !� .� .� 0� 0�0�c ���eZdZUdZdZeedfed<dZeedfed<e dde d e ed e ed e efd ���Z e de d ed ed efd ���Zeded efd���ZdS)�_Finderz@Base class that exposes functionality for module/package finders�.�ALWAYS_EXCLUDE�DEFAULT_EXCLUDE�.��*�where�exclude�includerc ���|p|j}t|�tt |����|jg|j�|�R�|j|�����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_iterr�str� _build_filterr!��clsr&r'r(s r�findz _Finder.findTsp��4�0�S�0��� �N�N��S��Z�Z�(�(�!��!�@�3�#5�@��@�@�@�!��!�7�+� � � � � rc��t�r)�NotImplementedErrorr.s rr+z_Finder._find_iterws��!�!r�patternsc����fd�S)z� Given a list of patterns, return a callable that will be true only if the input matches at least one of the patterns. c�<���t�fd��D����S)Nc3�8�K�|]}t�|��V��dSrr)�.0�pat�names �r� z:_Finder._build_filter....�s-�����K�K�3� �D�#� 6� 6�K�K�K�K�K�Kr)�any)r9r3s`�r�z'_Finder._build_filter..�s%����C�K�K�K�K�(�K�K�K�K�K�rr )r3s`rr-z_Finder._build_filter{s��� L�K�K�K�KrN)r#r r$)�__name__� __module__� __qualname__�__doc__r!rr,�__annotations__r"� classmethod�_Pathr r r0�_Filter�StrIterr+� staticmethodr-r rrrrNs�������J�J�&(�N�E�#�s�(�O�(�(�(�')�O�U�3��8�_�)�)�)���!#�!'�  �  ��  ��#��  ��#��  � �c��  �  �  ��[�  �D�"�u�"�w�"��"�W�"�"�"��[�"��L��L��L�L�L��\�L�L�Lrrc �b�eZdZdZdZededededefd���Z 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'r(rc#��K�tjt|��d���D]�\}}}|dd�}g|dd�<|D]�}tj�||��} tj�| |��} | �tjjd��} d|vs|�| | ��s��|| ��r|| ��s| V�|� |������dS)zy All the packages found in 'where' that pass the 'include' filter, but not the 'exclude' filter. T)� followlinksNr#) r�walkr,r�join�relpath�replace�sep�_looks_like_package�append) r/r&r'r(�root�dirs�files�all_dirs�dir� full_path�rel_path�packages rr+zPackageFinder._find_iter�s���� "$���U����!F�!F�!F� !� !� �D�$���A�A�A�w�H��D����G�� !� !���G�L�L��s�3�3� ��7�?�?�9�e�<�<��"�*�*�2�7�;��<�<���#�:�:�S�%<�%<�Y��%P�%P�:���7�7�#�#�"�G�G�G�,<�,<�"�!�M�M�M�� � �C� � � � � !�  !� !rr� _package_namec�|�tj�tj�|d����S)z%Does a directory look like a package?� __init__.py)rr�isfilerM)rr[s rrQz!PackageFinder._looks_like_package�s(���w�~�~�b�g�l�l�4��?�?�@�@�@rN)r=r>r?r@r!rBrCrDrEr+rFr,�boolrQr rrrHrH�s���������2�N��!�u�!�w�!��!�W�!�!�!��[�!�6�A�%�A��A��A�A�A��\�A�A�ArrHc�2�eZdZedededefd���ZdS)�PEP420PackageFinder�_pathr[rc��dS)NTr )rbr[s rrQz'PEP420PackageFinder._looks_like_package�s���trN)r=r>r?rFrCr,r_rQr rrrara�sG��������5���������\���rrac �P�eZdZdZededededefd���Ze e ��Z dS)� ModuleFinderzYFind isolated Python modules. This function will **not** recurse subdirectories. r&r'r(rc#�HK�ttj�|d����D]q}tj�tj�|����\}}|�|��s�W||��r||��s|V��rdS)Nz*.py)rrrrM�splitextr�_looks_like_module)r/r&r'r(�file�module�_exts rr+zModuleFinder._find_iter�s����������e�V�4�4�5�5� � �D��7�+�+�B�G�,<�,<�T�,B�,B�C�C�L�F�D��)�)�&�1�1� ���w�v��� �w�w�v��� �� � � �� � rN) r=r>r?r@rBrCrDrEr+rFrrhr rrrere�sh����������u��w����W�����[��&��k�2�2���rrec�t�eZdZdZeed�eD������Z edede de fd���Z dS)�FlatLayoutPackageFinder) �ci�bin�doc�docs� documentation�manpages�news� changelog�test�tests� unit_test� unit_tests�example�examples�scripts�tools�util�utils�python�build�dist�venv�env� requirements�tasks�fabfile� site_scons� benchmark� benchmarks�exercise� exercises�[._]*c#�$K�|] }||�d�fV�� dS)z.*Nr )r7�ps rr:z!FlatLayoutPackageFinder.�s,����&G�&G���a�8�8�8�}�&G�&G�&G�&G�&G�&Grrb� package_namerc���|�d��}|d���p|d�d��}|o td�|dd�D����S)Nr#r�-stubsc3�>K�|]}|���V��dSr)r)r7r9s rr:z>FlatLayoutPackageFinder._looks_like_package..�s.����(S�(S���):�):�)<�)<�(S�(S�(S�(S�(S�(Sr�)�splitr�endswith�all)rbr��names�root_pkg_is_valids rrQz+FlatLayoutPackageFinder._looks_like_package�sl���"�"�3�'�'��!�!�H�1�1�3�3�R�u�Q�x�7H�7H��7R�7R�� �S�S�(S�(S��q�r�r��(S�(S�(S�%S�%S�SrN) r=r>r?�_EXCLUDE�tuple� chain_iterr"rFrCr,r_rQr rrrmrm�s�������$�H�L�e�J�J�&G�&G�h�&G�&G�&G�G�G�H�H�O� ��T�5�T��T��T�T�T��\�T�T�Trrmc��eZdZdZdS)�FlatLayoutModuleFinder)�setup�conftestrvrwrzr{r��toxfile�noxfile�pavement�dodor�r�z[Ss][Cc]onstruct� conanfile�manager�r�r�r�r�N)r=r>r?r"r rrr�r��s�������O�4*�)rr��root_pkg�pkg_dirc�\��t�|��}�g�fd�|D��zS)Nc�>��g|]}d��|f����S)r#)rM)r7�nr�s �r� z)_find_packages_within..s)���A�A�A�Q����8�Q�-�0�0�A�A�Ar)rar0)r�r��nesteds` r�_find_packages_withinr�s8��� � %� %�g� .� .�F� �:�A�A�A�A�&�A�A�A� A�Arc�$�eZdZdZdd�Zd�Zd�Zedefd���Z ede e e ffd ���Z dd �Z d edefd�Zd edefd�Zdefd�Zdefd�Zdefd�Zdefd�Zdefd�Zdee de fd�Zd�Zdee fd�Zdee fd�ZdS)�ConfigDiscoveryz�Fill-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)�selfr�s r�__init__zConfigDiscovery.__init__$s%�� �� ��� ����!&����rc��d|_dS)z+Internal API to disable automatic discoveryTN)r��r�s r�_disablezConfigDiscovery._disable*s ������rc��d|_dS)a�Internal 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)r�r�s r�_ignore_ext_modulesz#ConfigDiscovery._ignore_ext_modules.s��"&����rrc�2�|jjp tjSr)r��src_rootr�curdirr�s r� _root_dirzConfigDiscovery._root_dir:s���y�!�.�R�Y�.rc�6�|jj�iS|jjSr)r�� package_dirr�s r� _package_dirzConfigDiscovery._package_dir?s�� �9� � (��I��y�$�$rFTc��|dur|js|jrdS|�|��|r|���d|_dS)a�Automatically 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)r�r��_analyse_package_layout� analyse_name)r��forcer9�ignore_ext_moduless r�__call__zConfigDiscovery.__call__EsX�� �E�>�>�t�|�>�t�~�>� �F� �$�$�%7�8�8�8� � � � � � � � ��� � � rr�c��|p|j}|jjdup| }|jjdup0|jjdup"|p t |jd��o |jjS)zF``True`` if the user has specified some form of package/module listingN� configuration)r�r�� ext_modules�packages� py_modules�hasattrr�)r�r�r�s r�_explicitly_specifiedz%ConfigDiscovery._explicitly_specifiedZsw��/�I�4�3I���9�0�D�8�N�.�sU����� � ���Z� "�#�r�w�|�|�H�j�'I�'I� J� J� � � � � � r�discovered packages -- T) r��copy�popr�rr�r��itemsr*r�r�)r�r��pkgsr�s @rr�z(ConfigDiscovery._analyse_explicit_layoutxs�����'�,�,�.�.� �����D�!�!�!��>��� ��5� � �J�[�J�J�K�K�K�� � � � �#.�#4�#4�#6�#6� � � � � ��"�$�Z�Z�� �� � �@�D�I�,>�@�@�A�A�A��trc��|j}tj�|j|�dd����}tj�|��sdStjd|����|� dtj� |����||j _ t�|��|j _t �|��|j _tjd|j j����tjd|j j����dS)a�Try 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"``. r��srcFz#`src-layout` detected -- analysing r��discovered py_modules -- T)r�rrrMr��get�isdirrr�� setdefaultrr�r�rar0r�rer�)r�r��src_dirs rr�z#ConfigDiscovery._analyse_src_layout�s���'� ��'�,�,�t�~�{���r�5�/I�/I�J�J���w�}�}�W�%�%� ��5� � �A��A�A�B�B�B����r�2�7�#3�#3�G�#<�#<�=�=�=� +�� ��0�5�5�g�>�>�� ��+�0�0��9�9�� �� � �@�D�I�,>�@�@�A�A�A� � �D�d�i�.B�D�D�E�E�E��trc��tjd|j����|���p|���S)a�Try 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 )rr�r��_analyse_flat_packages�_analyse_flat_modulesr�s rr�z$ConfigDiscovery._analyse_flat_layout�sB�� � �I���I�I�J�J�J��*�*�,�,�L��0J�0J�0L�0L�Lrc�,�t�|j��|j_t t |jj����}tjd|jj����|� |d��t|��S)Nr�r�) rmr0r�r�r��remove_nested_packages� remove_stubsrr��_ensure_no_accidental_inclusionr_)r�� top_levels rr�z&ConfigDiscovery._analyse_flat_packages�sv��4�9�9�$�.�I�I�� ��*�<�� �8J�+K�+K�L�L� � � �@�D�I�,>�@�@�A�A�A� �,�,�Y� �C�C�C��I���rc��t�|j��|j_t jd|jj����|�|jjd��t|jj��S)Nr��modules) r�r0r�r�r�rr�r�r_r�s rr�z%ConfigDiscovery._analyse_flat_modules�sh��5�:�:�4�>�J�J�� �� � �D�d�i�.B�D�D�E�E�E� �,�,�T�Y�-A�9�M�M�M��D�I�(�)�)�)r�detected�kindc��t|��dkr,ddlm}ddlm}d|�d|�d|�d�}|||�����dS) Nr�r)�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. )�len�inspectr��setuptools.errorsr�)r�r�r�r�r��msgs rr�z/ConfigDiscovery._ensure_no_accidental_inclusion�s��� �x�=�=�1� � � (� (� (� (� (� (� ?� ?� ?� ?� ?� ?��$���h��� NR� ���C�(�'���� � �6�6� 6�) � rc���|jjjs |jjrdStjd��|���p|���}|r||jj_dSdS)z�The 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)r��metadatar9rr��#_find_name_single_package_or_module�_find_name_from_packages)r�r9s rr�zConfigDiscovery.analyse_name�s��� �9� � "� �d�i�n� ��4� � �K�L�L�L� � 4� 4� 6� 6� /��,�,�.�.� � � +�&*�D�I� � #� #� #� +� +rc��dD]V}t|j|d��pg}|r:t|��dkr'tjd|d����|dcS�WdS)zExactly one module or package)r�r�Nr�z&Single module/package detected, name: r)�getattrr�r�rr�)r��fieldr�s rr�z3ConfigDiscovery._find_name_single_package_or_module�so��/� � �E��D�I�u�d�3�3�9�r�E�� ��U���q���� �M�5��8�M�M�N�N�N��Q�x������trc�"�|jjsdStt|jjt�����}|jjpi}t |||j��}|rtj d|����|Stj d��dS)zr?r@r�r�r��propertyrCr�r r,r�r�r_r�r�r�r�r�r�r�r r�r�rr�r�r rrr�r�s���������'�'�'�'� ��� &� &� &��/�5�/�/�/��X�/��%�d�3��8�n�%�%�%��X�%� ����*  ��  ��  �  �  �  � �$� �4� � � � �$�$�����$�T�����2 M�d� M� M� M� M�������*�t�*�*�*�*� 7��S� �7��7�7�7�7�.+�+�+�"�X�c�]������(�3�-������rr�r�c���t|t���}|dd�}t|��}tt|����D];\}�t �fd�|D����r|�||z dz ���<|S)z�Remove nested packages from a list of packages. >>> 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'] rNc3�H�K�|]}��|�d���V��dS�r#N�� startswith)r7�otherr9s �rr:z)remove_nested_packages.. s5�����C�C��t���%�{�{�{�+�+�C�C�C�C�C�Crr�)rr�� enumerate�reversedr;r�)r�r�r��size�ir9s @rr�r�s���� �(�� $� $� $�D��Q�Q�Q��I� �t�9�9�D��X�d�^�^�,�,�(�(���4� �C�C�C�C��C�C�C� C� C� (� �M�M�$��(�Q�,� '� '� '�� �rc��d�|D��S)z�Remove 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'] c�n�g|]2}|�d��d�d���0|��3S)r#rr�)r�r�)r7r�s rr�z remove_stubs..s:�� P� P� P�C�3�9�9�S�>�>�!�+<�+E�+E�h�+O�+O� P�C� P� P� Prr )r�s rr�r�s�� Q� P�8� P� P� P�Prr�r�c���t|t���}g}t|��D]B\}�t�fd�||dzd�D����sn|�����C|D]V�t �||��}t j�|d��}t j� |��r�cS�WdS)z0Find the parent package that is not a namespace.rc3�H�K�|]}|���d���V��dSr r )r7r�r9s �rr:z&find_parent_package.."s5�����D�D��1�<�<�4� � � �+�+�D�D�D�D�D�Drr�Nr]) rr�rr�rR�find_package_pathrrrMr^)r�r�r��common_ancestorsr�pkg_path�initr9s @rrrs�����h�C�(�(�(�H����X�&�&�&�&���4��D�D�D�D�X�a��c�d�d�^�D�D�D�D�D� � �E�����%�%�%�%� ����$�T�;��A�A���w�|�|�H�m�4�4�� �7�>�>�$� � � ��K�K�K� � �4rr9c��|�d��}tt|��dd��D]M}d�|d|���}||vr*||}t jj||g||d��R�cS�N|�d��pd}t jj|g|�d���|�R�S)a�Given 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#r�����Nr��/)r��ranger�rMrrr�)r9r�r��partsr� partial_name�parents rrr3s���, �J�J�s�O�O�E� �3�u�:�:�q�"� %� %�>�>���x�x��b�q�b� �*�*� � �;� &� &� ��.�F��7�<��&�=�5����9�=�=�=� =� =� =� '��_�_�R� � � &�B�F� �7�<�� =�6�<�<��#4�#4� =�u� =� =� =�=r� package_pathc�f��t|��}t|��j��fd�|D��S)Nc �j��i|]/}|d�g��|�d�������0S)rr#)rMr�)r7r��prefixs �r� z)construct_package_dir..Xs<��� M� M� M�#�C����4�F�4�S�Y�Y�s�^�^�4�5�5� M� M� Mr)r�rr )r�r#� parent_pkgsr&s @r�construct_package_dirr)Us:���(��2�2�K� �,� � � %�F� M� M� M� M�� M� M� M�Mr)2r@� itertoolsr�fnmatchrr�pathlibr�typingrrr r r r r rrr�_distutils_hack.override�_distutils_hack� distutilsr�distutils.utilrr,�PathLikerCr_rDrE�chain� from_iterabler�� setuptoolsrrrrHrarermr�r�r�r�r�rrr)r rr�r6s��%�%�N���� � � � ������������������� � � � � � � � � � � � � � � � � � � � � � � � � ����������'�'�'�'�'�'� �c�2�;���� �C�5�$�;� �� �3�-�� �_� *� ��(�'�'�'�'�'�'�1�e�1��1�1�1�1� 3L�3L�3L�3L�3L�3L�3L�3L�l&A�&A�&A�&A�&A�G�&A�&A�&A�R�����-���� 3�3�3�3�3�7�3�3�3�./T�/T�/T�/T�/T�1�/T�/T�/T�d*�*�*�*�*�\�*�*�*�<B�C�B�%�B�D��I�B�B�B�B� ^�^�^�^�^�^�^�^�B�T�#�Y��4��9�����$Q�4��9�Q��c��Q�Q�Q�Q���3�i��&-�c�3�h�&7��CH�� �c�]�����0>� �>�#�C��H�-�>�9>�>��>�>�>�>�DN�D��I�N�U�N�t�C�QT�H�~�N�N�N�N�N�Nr