� u��g S����dZddlmZddlZddlZddlmZmZmZddl m Z ddl m Z ddl m Z ddlmZmZddlZd d lmZdd lmZdd lmZerdd lmZejjZd5d�ZGd�d��ZGd�d��Z Gd�de ��Z!Gd�de!��Z"Gd�de ��Z#Gd�de"��Z$Gd�d e#��Z%d6d%�Z&Gd&�d'��Z'd7d)�Z(d7d*�Z)d8d/�Z*d9d1�Z+d:d4�Z,dS);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 �)� annotationsN)�Iterable�Iterator�Mapping�� fnmatchcase)�glob)�Path)� TYPE_CHECKING�ClassVar�)�StrPath)�log)� convert_path)� Distribution�pathr�return�boolc�d�tj�|�����S�N)�osr�basename� isidentifier)rs �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/setuptools/discovery.py� _valid_namer?s$�� �7� � �D� !� !� .� .� 0� 0�0�c�*�eZdZdZd d�Zd d �Zd d �Zd S)�_Filterz� Given a list of patterns, create a callable that will be true only if the input matches at least one of the patterns. �patterns�strr�Nonec�D�t�|��|_dSr)�dict�fromkeys� _patterns)�selfrs r�__init__z_Filter.__init__Js�����x�0�0����r�itemrc�D��t�fd�|jD����S)Nc3�8�K�|]}t�|��V��dSrr)�.0�patr(s �r� <genexpr>z#_Filter.__call__.<locals>.<genexpr>Ns-�����D�D�c�;�t�S�)�)�D�D�D�D�D�Dr)�anyr%�r&r(s `r�__call__z_Filter.__call__Ms(����D�D�D�D�T�^�D�D�D�D�D�Drc��||jvSr)r%r/s r� __contains__z_Filter.__contains__Ps���t�~�%�%rN)rr rr!)r(r rr)�__name__� __module__� __qualname__�__doc__r'r0r2�rrrrDs^�������� 1�1�1�1�E�E�E�E�&�&�&�&�&�&rrc�h�eZdZUdZdZded<dZded<e ddd���Zedd���Z dS)�_Finderz@Base class that exposes functionality for module/package findersr7zClassVar[tuple[str, ...]]�ALWAYS_EXCLUDE�DEFAULT_EXCLUDE�.��*�wherer�exclude� Iterable[str]�includer� list[str]c ���|p|j}t|�tt |����t g|j�|�R�t |�����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_iterrr rr:��clsr?r@rBs r�findz _Finder.findZsf��4�0�S�0��� �N�N��S��Z�Z�(�(��6��+�6�g�6�6�6���!� � � � � rr� Iterator[str]c��t�r)�NotImplementedErrorrGs rrFz_Finder._find_iter}s ��"�!rN)r<r7r=)r?rr@rArBrArrC�r?rr@rrBrrrJ) r3r4r5r6r:�__annotations__r;� classmethodrIrFr7rrr9r9Ts��������J�J�02�N�2�2�2�2�13�O�3�3�3�3���!#�!'�  �  �  �  ��[�  �D�"�"�"��[�"�"�"rr9c�F�eZdZdZdZedd ���Zedd���ZdS)� PackageFinderzI Generate a list of all Python packages found within a directory )�ez_setupz *__pycache__r?rr@rrBrrJc#�K�tjt|��d���D]�\}}}|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>�.*) r�walkr r�join�relpath�replace�sep�_looks_like_package�append) rHr?r@rB�root�dirs�files�all_dirs�dir� full_path�rel_path�packages rrFzPackageFinder._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��=�=�=�G�+�+�'�~�~�~��/H�/H��� � �C� � � � �' !�  !� !rr� _package_namer rc�|�tj�tj�|d����S)z%Does a directory look like a package?� __init__.py)rr�isfilerW)rres rr[z!PackageFinder._looks_like_package�s(���w�~�~�b�g�l�l�4��?�?�@�@�@rNrM)rrrer rr) r3r4r5r6r:rOrF� staticmethodr[r7rrrQrQ�sj��������2�N��!�!�!��[�!�B�A�A�A��\�A�A�ArrQc�&�eZdZed d���ZdS) �PEP420PackageFinder�_pathrrer rrc��dS)NTr7)rlres rr[z'PEP420PackageFinder._looks_like_package�s���trN)rlrrer rr)r3r4r5rir[r7rrrkrk�s2�����������\���rrkc�@�eZdZdZed d ���Zee��Zd S) � ModuleFinderzYFind isolated Python modules. This function will **not** recurse subdirectories. r?rr@rrBrrJc#�HK�ttj�|d����D]q}tj�tj�|����\}}|�|��s�W||��r||��s|V��rdS)Nz*.py)r rrrW�splitextr�_looks_like_module)rHr?r@rB�file�module�_exts rrFzModuleFinder._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��� �� � � �� � rNrM) r3r4r5r6rOrFrirrrr7rrroro�sL��������� � � ��[� �&��k�2�2���rroc�h�eZdZdZeed�eD������Z ed d ���Zd S) �FlatLayoutPackageFinder)#�ci�bin�debian�doc�docs� documentation�manpages�news� newsfragments� 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�htmlcov�[._]*c#�$K�|] }||�d�fV�� dS)rUNr7)r+�ps rr-z!FlatLayoutPackageFinder.<genexpr>�s,����&G�&G���a�8�8�8�}�&G�&G�&G�&G�&G�&Grrlr� package_namer rrc���|�d��}|d���p|d�d��}|o td�|dd�D����S)Nr<r�-stubsc3�>K�|]}|���V��dSr)r)r+�names rr-z>FlatLayoutPackageFinder._looks_like_package.<locals>.<genexpr>s.����(S�(S���):�):�)<�)<�(S�(S�(S�(S�(S�(Srr )�splitr�endswith�all)rlr��names�root_pkg_is_valids rr[z+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)rlrr�r rr) r3r4r5�_EXCLUDE�tuple� chain_iterr;rir[r7rrrwrw�sm������'�H�R�e�J�J�&G�&G�h�&G�&G�&G�G�G�H�H�O� ��T�T�T��\�T�T�Trrwc��eZdZdZdS)�FlatLayoutModuleFinder)�setup�conftestr�r�r�r�r��toxfile�noxfile�pavement�dodor�r�z[Ss][Cc]onstruct� conanfile�manager�r�r�r�r�N)r3r4r5r;r7rrr�r�s�������O�4*�)rr��root_pkgr �pkg_dirrCc�\��t�|��}�g�fd�|D��zS)Nc�>��g|]}d��|f����S)r<)rW)r+�nr�s �r� <listcomp>z)_find_packages_within.<locals>.<listcomp>'s)���A�A�A�Q����8�Q�-�0�0�A�A�Ar)rkrI)r�r��nesteds` r�_find_packages_withinr�%s8��� � %� %�g� .� .�F� �:�A�A�A�A�&�A�A�A� A�Arc��eZdZdZd%d�Zd�Zd�Zed&d ���Zed'd ���Z d(d)d�Z d*d�Z d*d�Z d+d�Z d+d�Zd+d�Zd+d�Zd+d�Zd,d�Zd-d �Zd.d"�Zd.d#�Zd$S)/�ConfigDiscoveryz�Fill-in metadata and options that can be automatically derived (from other metadata/options, the file system or conventions) � distributionrrr!c�>�||_d|_d|_d|_dS)NF)r��_called� _disabled�_skip_ext_modules)r&r�s rr'zConfigDiscovery.__init__/s%�� �� ��� ����!&����rc��d|_dS)z+Internal API to disable automatic discoveryTN)r��r&s r�_disablezConfigDiscovery._disable5s ������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_modules9s��"&����rrc�2�|jjp tjSr)r��src_rootr�curdirr�s r� _root_dirzConfigDiscovery._root_dirEs���y�!�.�R�Y�.r�dict[str, str]c�6�|jj�iS|jjSr)r�� package_dirr�s r� _package_dirzConfigDiscovery._package_dirJs�� �9� � (��I��y�$�$rFT�forcerr��ignore_ext_modulesc��|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&r�r�r�s rr0zConfigDiscovery.__call__PsX�� �E�>�>�t�|�>�t�~�>� �F� �$�$�%7�8�8�8� � � � � � � � ��� � � rc��|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_specifiedgsw��/�I�4�3I���9�0�D�8�N�<N�O� � �I� �d� *� (��y�#�4�/� (�� (��t�y�/�2�2�(�� �'�  rc���|�|��rdStjd��|���p'|���p|���S)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�z'ConfigDiscovery._analyse_package_layouttsy�� � %� %�&8� 9� 9� ��4� � � #� � � � � )� )� +� +� +��'�'�)�)� +��(�(�*�*�  rc�x��|j���}|�dd��|j�|sdSt jd|����t �fd�|���D����}t|��|j _ t jd|j j ����dS)zAThe user can explicitly give a package layout via ``package_dir``�NFz(`explicit-layout` detected -- analysing c3�z�K�|]5\}}t|tj��|����V��6dSr)r�rrrW)r+�pkg� parent_dir�root_dirs �rr-z;ConfigDiscovery._analyse_explicit_layout.<locals>.<genexpr>�sU����� � ���Z� "�#�r�w�|�|�H�j�'I�'I� J� J� � � � � � r�discovered packages -- T) r��copy�popr�rr�r��itemsrEr�r�)r&r��pkgsr�s @rr�z(ConfigDiscovery._analyse_explicit_layout�s�����'�,�,�.�.� �����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�rrrWr��get�isdirrr�� setdefaultrr�r�rkrIr�ror�)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�) rwrIr�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�rIr�r�r�rr�r�rr�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�detectedrC�kindr c��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�rr�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��metadatar�rr��#_find_name_single_package_or_module�_find_name_from_packages)r&r�s rr�zConfigDiscovery.analyse_name�s��� �9� � "� �d�i�n� � �F� � �K�L�L�L� � 4� 4� 6� 6� /��,�,�.�.� � � +�&*�D�I� � #� #� #� +� +r� str | Nonec��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�rrr�)r&�fieldr�s rrz3ConfigDiscovery._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)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�� parent_pkgs rr z(ConfigDiscovery._find_name_from_packages�s����y�!� ��4���t�y�'9�s� C� C� C�D�D���i�+�1�r� �(��;���O�O� � � � �I�K�z�K�K� L� L� L�� � ��J�K�K�K��trN)r�rrr!)rr)rr�)FTF)r�rr�rr�r)r�rrr)rr)r�rCr�r )rr!)rr )r3r4r5r6r'r�r��propertyr�r�r0r�r�r�r�r�r�r�r�r�rr r7rrr�r�*s���������'�'�'�'� ��� &� &� &��/�/�/��X�/��%�%�%��X�%� RW������.  �  �  �  � � � � �$����$����2 M� M� M� M�����*�*�*�*� 7�7�7�7�.+�+�+�+�"���������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)r+�otherr�s �rr-z)remove_nested_packages.<locals>.<genexpr>s5�����C�C��t���%�{�{�{�+�+�C�C�C�C�C�Crr )rr� enumerate�reversedr.r�)r�r�r��size�ir�s @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�)r+r�s rr�z remove_stubs.<locals>.<listcomp>&s:�� P� P� P�C�3�9�9�S�>�>�!�+<�+E�+E�h�+O�+O� P�C� P� P� Prr7)r�s rr�r� s�� Q� P�8� P� P� P�Prr��Mapping[str, str]r�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��dSrr)r+r�r�s �rr-z&find_parent_package.<locals>.<genexpr>0s5�����G�G��1�<�<�4� � � �+�+�G�G�G�G�G�Grr Nrg) rrrr�r\�find_package_pathrrrWrh)r�r�r��common_ancestorsr�pkg_path�initr�s @rrr)s�����h�C�(�(�(�H����X�&�&�&�&���4��G�G�G�G�X�a�!�e�g�g�5F�G�G�G�G�G� � �E�����%�%�%�%� ����$�T�;��A�A���w�|�|�H�m�4�4�� �7�>�>�$� � � ��K�K�K� � �4rr�c��|�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��rangerrWrrr�)r�r�r��partsr� partial_name�parents rr%r%As���, �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_pathr�c�f��t|��}t|��j��fd�|D��S)Nc �j��i|]/}|d�g��|�d�������0S)r+r<)rWr�)r+r��prefixs �r� <dictcomp>z)construct_package_dir.<locals>.<dictcomp>fs<��� M� M� M�#�C����4�F�4�S�Y�Y�s�^�^�4�5�5� M� M� Mr)r�r r-)r�r0� parent_pkgsr3s @r�construct_package_dirr6cs:���(��2�2�K� �,� � � %�F� M� M� M� M�� M� M� M�Mr)rrrr)r�r r�rrrC)r�rCrrC)r�rCr�r"r�rrr )r�r r�r"r�rrr )r�rCr0rrr�)-r6� __future__r� itertoolsr�collections.abcrrr�fnmatchrr �pathlibr �typingr r �_distutils_hack.override�_distutils_hackrlr� distutilsr�distutils.utilr� setuptoolsr�chain� from_iterabler�rrr9rQrkrorwr�r�r�r�r�rr%r6r7rr�<module>rDs��%�%�N#�"�"�"�"�"����� � � � �7�7�7�7�7�7�7�7�7�7�������������������*�*�*�*�*�*�*�*�����������������'�'�'�'�'�'��(�'�'�'�'�'�'� �_� *� �1�1�1�1� &� &� &� &� &� &� &� &� -"�-"�-"�-"�-"�-"�-"�-"�`,A�,A�,A�,A�,A�G�,A�,A�,A�^�����-���� 3�3�3�3�3�7�3�3�3�22T�2T�2T�2T�2T�1�2T�2T�2T�j*�*�*�*�*�\�*�*�*�<B�B�B�B� a�a�a�a�a�a�a�a�H����$Q�Q�Q�Q�����0>�>�>�>�DN�N�N�N�N�Nr
Memory