� w��g�>��Z�dZddlmZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl m Z ddlmZddlmZmZddlmZdd lmZdd lmZmZdd lmZmZmZmZd d lmZd dl m!Z!m"Z#d dl$m%Z%d dl&m'Z'ddl(m)Z)er ddl*m+Z+ddl,m-Z-ed��Z.edd���Z/Gd�d��Z0 d\d]d �Z1 d\d^d$�Z2d_d'�Z3d`d*�Z4dad,�Z5 dbdcd1�Z6ddd5�Z7ded8�Z8dfd:�Z9 dbdgd=�Z: dbdhdA�Z;ddddB�didE�Z<djdH�Z=dkdK�Z>dldN�Z? d\dmdR�Z@ dndodW�ZAGdX�dY��ZBGdZ�d[e e.e/f��ZCdS)paiUtility 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. �)� annotationsN)�Iterable�Iterator�Mapping)� ConfigParser)�iglob)� ModuleSpec� all_suffixes)�chain)�Path)� ModuleType� TracebackType)� TYPE_CHECKING�Any�Callable�TypeVar�)�_static)�StrPath� same_path)�find_package_path)�SetuptoolsWarning)�DistutilsOptionError)�Self)� Distribution�_K�_V_coT)� covariantc�*�eZdZdZdd�Zdd �Zdd �Zd S)� StaticModulez>Proxy to a module object that avoids executing arbitrary code.�name�str�specr �return�Nonec���tjtj|j�������}t |���t����|` dS�N) �ast�parse�pathlibr �origin� read_bytes�vars�update�locals�self)r0r!r#�modules �h/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/setuptools/config/expand.py�__init__zStaticModule.__init__8sP����7�<�� �4�4�?�?�A�A�B�B�� �T� � ���&�(�(�#�#�#� �I�I�I��!Iterator[tuple[ast.AST, ast.AST]]c#���K�|jjD]g�t�tj��r�fd��jD��Ed{V���6t�tj��r�jr�j�jfV��hdS)Nc3�*�K�|] }|�jfV��dSr')�value)�.0�target� statements �r2� <genexpr>z1StaticModule._find_assignments.<locals>.<genexpr>@s*�����V�V�&�V�Y�_�5�V�V�V�V�V�Vr4) r1�body� isinstancer(�Assign�targets� AnnAssignr8r:)r0r;s @r2�_find_assignmentszStaticModule._find_assignments=s��������)� :� :�I��)�S�Z�0�0� :�V�V�V�V�I�DU�V�V�V�V�V�V�V�V�V�V�V��I�s�}�5�5� :�)�/� :� �'���9�9�9�9��  :� :r4�attrc��� t�fd�|���D����S#t$r}t|j�d�����|�d}~wwxYw)zHAttempt to load an attribute "statically", via :func:`ast.literal_eval`.c3��K�|]@\}}t|tj��r!|j�k�*tj|��V��AdSr')r>r(�Name�id� literal_eval)r9r:r8rCs �r2r<z+StaticModule.__getattr__.<locals>.<genexpr>Gsa�������!�F�E��f�c�h�/�/��5;�I��4E�4E�� ��'�'�4E�4E�4E�4E��r4z has no attribute N)�nextrB� Exception�AttributeErrorr!)r0rC�es ` r2� __getattr__zStaticModule.__getattr__Ds���� P������%)�%;�%;�%=�%=������ �� � P� P� P� �D�I�!G�!G��!G�!G�H�H�a� O����� P���s�,0� A�A�AN)r!r"r#r r$r%)r$r5)rCr")�__name__� __module__� __qualname__�__doc__r3rBrM�r4r2r r 5s\������H�H����� :�:�:�:� P� P� P� P� P� Pr4r �patterns� Iterable[str]�root_dir�StrPath | Noner$� list[str]c ����hd�}g}�ptj���|D]�t�fd�|D����r{tj�tj�������}|�t�fd�t|d���D��������tj� ����� tj d��}|� |����|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�|]}|�vV�� dSr'rR)r9�charr8s �r2r<z glob_relative.<locals>.<genexpr>_s'�����9�9��t�u�}�9�9�9�9�9�9r4c3��K�|]B}tj�|����tjd��V��CdS)�/N)�os�path�relpath�replace�sep�r9rdrUs �r2r<z glob_relative.<locals>.<genexpr>csY���������G�O�O�D�(�3�3�;�;�B�F�C�H�H������r4T)� recursiverb) rc�getcwd�anyrd�abspath�join�extend�sortedrrerfrg�append)rSrU�glob_characters�expanded_values� glob_pathrdr8s ` @r2� glob_relativertPs ����5�4�4�O��O��&�2�9�;�;�H��)�)�� �9�9�9�9��9�9�9� 9� 9� )������� � �X�u�(E�(E�F�F�I� � "� "������ %�i�4� @� @� @������ � � � ��7�?�?�5�(�3�3�;�;�B�F�C�H�H�D� � "� "�4� (� (� (� (� �r4� filepaths�StrPath | Iterable[StrPath]r"c����ddlm}tj��ptj������fd�||��D��}d��fd�t|��D����S)z�Return 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�X�K�|]$}tj��|��V��%dSr'�rcrdrmrhs �r2r<zread_files.<locals>.<genexpr>}s3�����V�V�4�"�'�,�,�x��.�.�V�V�V�V�V�Vr4� c3�V�K�|]#}t|����t|��V��$dSr')� _assert_local� _read_filerhs �r2r<zread_files.<locals>.<genexpr>~sO������� � ��x� (� (���4��������r4)�more_itertoolsrxrcrdrlrjrm�_filter_existing_files)rurUrx� _filepathss ` r2� read_filesr�qs����/�.�.�.�.�.��w���x�6�2�9�;�;�7�7�H�V�V�V�V�?�?�9�;U�;U�V�V�V�J� �9�9�����*�:�6�6���� � �r4�Iterable[StrPath]�Iterator[StrPath]c#�K�|D]>}tj�|��r|V��&tjd|�d����?dS)NzFile z cannot be found)rcrd�isfiler�emit)rurds r2r�r��se�����E�E�� �7�>�>�$� � � E��J�J�J�J� � "�#C�4�#C�#C�#C� D� D� D� D� E�Er4�filepath�bytes | StrPathc��t|d���5}|���cddd��S#1swxYwYdS)Nzutf-8)�encoding)�open�read)r��fs r2r~r~�s��� �h�� )� )� )��Q��v�v�x�x���������������������s �3�7�7rc���ttj�|����ttj�|����jvrd|�d|�d�}t |���dS)NzCannot access z (or anything outside �)T)r rcrdrl�parentsr)r�rU�msgs r2r}r}�sg�� �B�G�O�O�H� %� %�&�&�d�2�7�?�?�8�3L�3L�.M�.M�.U�U�U�N�x�N�N��N�N�N��"�3�'�'�'� �4r4� attr_desc� package_dir�Mapping[str, str] | Nonerc���|ptj��}|����d��}|���}d�|��}|pd}t |||��}t||��} tt||��|��}tj |��S#t$r#t||��} t| |��cYSwxYw)a�Reads 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 �.r3)rcrj�strip�split�poprm� _find_module� _find_spec�getattrr r�attempt_conversionrJ� _load_spec) r�r�rU� attrs_path� attr_name� module_namerdr#r8r1s r2� read_attrr��s���,�&�2�9�;�;�H����"�"�(�(��-�-�J���� � �I��(�(�:�&�&�K��+��K� � �[�(� ;� ;�D� �k�4� (� (�D�*�� �[�$�7�7��C�C���)�%�0�0�0�� �*�*�*��D�+�.�.���v�y�)�)�)�)�)�*���s� 1B>�>*C+�*C+r�� module_pathr c��tj�||��}|ptj�|��}|�t |���|Sr')� importlib�util�spec_from_file_location� find_spec�ModuleNotFoundError)r�r�r#s r2r�r��sK�� �>� 1� 1�+�{� K� K�D� � 8�9�>�+�+�K�8�8�D� �|�!�+�.�.�.� �Kr4r#r c� �t|d|��}|tjvrtj|Stj�|��}|tj|<|j�J�|j�|��|S)NrN)r��sys�modulesr�r��module_from_spec�loader� exec_module)r#r�r!r1s r2r�r��sw�� �4��[� 1� 1�D� �s�{����{�4� � � �^� ,� ,�T� 2� 2�F��C�K��� �;� "� "� "��K���F�#�#�#� �Mr4� str | Nonec���t||pi|���tj�fd�t��D����}t d�|D��d��S)a�Find the path to the module named ``module_name``, considering the ``package_dir`` in the build configuration and ``root_dir``. >>> tmp = getfixture('tmpdir') >>> _ = tmp.ensure("a/b/c.py") >>> _ = tmp.ensure("a/b/d/__init__.py") >>> r = lambda x: x.replace(str(tmp), "tmp").replace(os.sep, "/") >>> r(_find_module("a.b.c", None, tmp)) 'tmp/a/b/c.py' >>> r(_find_module("f.g.h", {"": "1", "f": "2", "f.g": "3", "f.g.h": "a/b/d"}, tmp)) 'tmp/a/b/d/__init__.py' c3�j�K�|]-}��|��tj��d|����fV��.dS)r3Nrz)r9�ext� path_starts �r2r<z_find_module.<locals>.<genexpr>�s`�����%�%� � � �� � �r�w�|�|�J�8H�3�8H�8H�I�I�J�%�%�%�%�%�%r4c3�XK�|]%}tj�|���!|V��&dSr')rcrdr�)r9�xs r2r<z_find_module.<locals>.<genexpr>�s5����<�<�q�"�'�.�.��*;�*;�<��<�<�<�<�<�<r4N)rr � from_iterabler rI)r�r�rU� candidatesr�s @r2r�r��sx���#�;� �0A�r�8�L�L�J��$�%�%�%�%��>�>�%�%�%���J� �<�<�J�<�<�<�d� C� C�Cr4�qualified_class_namerc��|ptj��}|�d��}||dzd�}|d|�}t|||��}t t ||��|��}t ||��S)z@Given a qualified class name, return the associated class objectr��N)rcrj�rfindr�r�r�r�)r�r�rU�idx� class_name�pkg_namerdr1s r2� resolve_classr��s��� �&�2�9�;�;�H� � $� $�S� )� )�C�%�c�A�g�i�i�0�J�#�D�S�D�)�H� ��+�x� 8� 8�D� � �8�T�2�2�H� =� =�F� �6�:� &� &�&r4�values�dict[str, str]�dict[str, Callable]c�H�����fd�|���D��S)z�Given a dictionary mapping command names to strings for qualified class names, apply :func:`resolve_class` to the dict values. c�:��i|]\}}|t|������SrR)r�)r9�k�vr�rUs ��r2� <dictcomp>zcmdclass.<locals>.<dictcomp>s+��� R� R� R�4�1�a�A�}�Q� �X�6�6� R� R� Rr4)�items)r�r�rUs ``r2�cmdclassr��s,���� S� R� R� R� R�6�<�<�>�>� R� R� R�Rr4)� namespaces�fill_package_dirrUr��dict[str, str] | Nonec �� �ddlm}m}ddlm}|sddlm}nddlm}|p tj}|� ddg��}g} |�in|}t|||������� t� ��d kr9t� fd �d|fD����r|� d � d��� D]�} t|| ��} |j| fi|��} | �| ��| rX|�d ��| ks?tj�| |��s|�|| | ������| 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)rx�unique_everseen)�construct_package_dir)� PackageFinder)�PEP420PackageFinder�wherer�Nr�c3�F�K�|]}t�d|�� V��dS)rN)� _same_path)r9r��searchs �r2r<z find_packages.<locals>.<genexpr>1s4�����V�V��J�v�a�y�!�$<�$<� <�V�V�V�V�V�Vr4�)rrxr��setuptools.discoveryr�r�r�rc�curdirr��list�len�all� setdefault� _nest_path�findrn�getrd�samefiler.)r�r�rU�kwargsrxr�r�r�r��packagesrd� package_path�pkgsr�s @r2� find_packagesr� s����0@�?�?�?�?�?�?�?�:�:�:�:�:�:� �N�6�6�6�6�6�6�6�M�M�M�M�M�M��$�2�9�H� �J�J�w��� &� &�E��H�-�5�r�r�;K�� �/�/�/�/�%�"8�"8�9�9� :� :�F� �6�{�{�a���C�V�V�V�V�s�H�o�V�V�V�V�V���#�#�B��q� �2�2�2��G�G��!�(�D�1�1� �!�}�!�,�9�9�&�9�9��������� � G� � � �� $� $�� ,� ,���0@�0@��x�0X�0X� ,� � #� #�$9�$9�$��$E�$E� F� F� F�� �Or4�parentrdc��|dvr|ntj�||��}tj�|��S)N>r�r�)rcrdrm�normpath)r�rds r2r�r�@s;���Y�&�&�6�6�B�G�L�L���,F�,F�D� �7� � �D� !� !�!r4r8�$Callable | Iterable[str | int] | strc���t|��r |��n|}t|t��r|St|d��r(d�t t|����S|�S)z`When getting the version directly from an attribute, it should be normalised to string. �__iter__r�)�callabler>r"�hasattrrm�map)r8�_values r2�versionr�Esk��!���� 2�U�U�W�W�W�U�F��&�#����� ��v�z�"�"�*��x�x��C��(�(�)�)�)��;�r4� package_data�dictc�>�d|vr|�d��|d<|S)NrYr�)r�)r�s r2�canonic_package_datar�Rs+�� �l���'�+�+�C�0�0� �R�� �r4� data_files� list | dict�list[tuple[str, list[str]]]c�r��t|t��r|S�fd�|���D��S)z�For compatibility with ``setup.py``, ``data_files`` should be a list of pairs instead of a dict. This function also expands glob patterns. c�:��g|]\}}|t|���f��SrR)rt)r9�destrSrUs �r2� <listcomp>z&canonic_data_files.<locals>.<listcomp>cs<��� � � � �D�(� �}�X�x�0�0�1� � � r4)r>r�r�)r�rUs `r2�canonic_data_filesr�XsT����*�d�#�#���� � � � �(�.�.�0�0� � � �r4� entry-points�text� text_source�dict[str, dict[str, str]]c���tdd���}t|_|�||��d�|���D��}|�|jd��|S)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� delimitersc�X�i|]'\}}|t|�������(SrR)r�r�)r9r�r�s r2r�z entry_points.<locals>.<dictcomp>vs,�� <� <� <�T�Q��a��a�g�g�i�i��� <� <� <r4)rr"� optionxform� read_stringr�r�r)rr�parser�groupss r2� entry_pointsr isk���$�6� B� B� B�F��F�� ���t�[�)�)�)� <� <�V�\�\�^�^� <� <� <�F� �J�J�v�%�t�,�,�,� �Mr4c�P�eZdZdZdd�Zd�Zdd �Zdd�Zdd�Ze dd���Z dS)�EnsurePackagesDiscovereda�Some 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. � distributionrr$r%c�"�||_d|_dS)NF)�_dist�_called)r0rs r2r3z!EnsurePackagesDiscovered.__init__�s��!�� ��� � � r4c�\�|js$d|_|j�d���dSdS)zBTrigger the automatic package discovery, if it is still necessary.TF)r!N)rr� set_defaults�r0s r2�__call__z!EnsurePackagesDiscovered.__call__�s<���|� 0��D�L� �J� #� #�� #� /� /� /� /� /� 0� 0r4rc��|Sr'rRrs r2� __enter__z"EnsurePackagesDiscovered.__enter__�s��� r4�exc_type�type[BaseException] | None� exc_value�BaseException | None� traceback�TracebackType | Nonec�T�|jr |jj���dSdSr')rrr� analyse_name)r0rrrs r2�__exit__z!EnsurePackagesDiscovered.__exit__�s5�� �<� 3� �J� #� 0� 0� 2� 2� 2� 2� 2� 3� 3r4�Mapping[str, str]c�:�|��|jj}|�in|Sr')rr�)r0�pkg_dirs r2�_get_package_dirz)EnsurePackagesDiscovered._get_package_dir�s%�� ������*�(���_�r�r�'�1r4c�*�t|j��S)zCProxy to ``package_dir`` that may trigger auto-discovery when used.)�LazyMappingProxyr%rs r2r�z$EnsurePackagesDiscovered.package_dir�s�� �� 5�6�6�6r4N)rrr$r%)r$r)rrrrrr)r$r") rNrOrPrQr3rrr!r%�propertyr�rRr4r2rr{s�������������0�0�0� ����3�3�3�3�2�2�2�2� �7�7�7��X�7�7�7r4rc�:�eZdZdZdd�Zdd�Zdd �Zdd�Zdd�ZdS)r'a�Mapping 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_value� Callable[[], Mapping[_K, _V_co]]r$r%c�"�||_d|_dSr')�_obtainr�)r0r*s r2r3zLazyMappingProxy.__init__�s��+�� �15�� � � r4�Mapping[_K, _V_co]c�P�|j�|���|_|jSr')r�r-rs r2�_targetzLazyMappingProxy._target�s!�� �;� ��,�,�.�.�D�K��{�r4�keyrrc�6�|���|Sr')r0)r0r1s r2� __getitem__zLazyMappingProxy.__getitem__�s���|�|�~�~�c�"�"r4�intc�D�t|�����Sr')r�r0rs r2�__len__zLazyMappingProxy.__len__�s���4�<�<�>�>�"�"�"r4� Iterator[_K]c�D�t|�����Sr')�iterr0rs r2r�zLazyMappingProxy.__iter__�s���D�L�L�N�N�#�#�#r4N)r*r+r$r%)r$r.)r1rr$r)r$r4)r$r7) rNrOrPrQr3r0r3r6r�rRr4r2r'r'�s������� � �6�6�6�6����� #�#�#�#�#�#�#�#�$�$�$�$�$�$r4r'r')rSrTrUrVr$rW)rurvrUrVr$r")rur�r$r�)r�r�r$r")r�rrUr")NN)r�r"r�r�rUrVr$r)r�r"r�rVr$r )r#r r�r"r$r )r�r"r�r�rUrr$r�)r�r"r�r�rUrVr$r)r�r�r�r�rUrVr$r�)r�r�rUrVr$rW)r�rrdrr$r")r8r�r$r")r�r�r$r�)r�r�rUrVr$r�)r�)rr"rr"r$r)DrQ� __future__rr(r�rcr*r��collections.abcrrr� configparserr�globr�importlib.machineryr r � itertoolsr r �typesr r�typingrrrrr�r�_pathrrr�� discoveryr�warningsr�distutils.errorsr�typing_extensionsr�setuptools.distrrrr rtr�r�r~r}r�r�r�r�r�r�r�r�r�r�r�r rr'rRr4r2�<module>rHs����(#�"�"�"�"�"� � � � ����� � � � ����� � � � �7�7�7�7�7�7�7�7�7�7�%�%�%�%�%�%�������8�8�8�8�8�8�8�8�������������+�+�+�+�+�+�+�+�8�8�8�8�8�8�8�8�8�8�8�8�������4�4�4�4�4�4�4�4�)�)�)�)�)�)�(�(�(�(�(�(�1�1�1�1�1�1��-�&�&�&�&�&�&�,�,�,�,�,�,� �W�T�]�]�����4�(�(�(��P�P�P�P�P�P�P�P�89=������DHL������(E�E�E�E����� ����-1�#�%*�%*�%*�%*�%*�P��������D�D�D�D�2-1�#� '� '� '� '� '�$-1�#�S�S�S�S�S��.2�#� 4�4�4�4�4�4�n"�"�"�"� � � � �����9=������$#1������$(7�(7�(7�(7�(7�(7�(7�(7�V$�$�$�$�$�w�r�5�y�)�$�$�$�$�$r4
Memory