� ��^i���ddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZddlmZmZmZddlmZddlmZded efd �Zd ed ed dfd �Zded efd�Zedede d ee fd���Zeded��ed�����Z e ej!��Z!ded efd�Z"ded efd�Z#deded eefd�Z$ded ee%e&ffd�Z'ded efd�Z(ded ee%e&ffd�Z)ded efd�Z*dS)�N)�contextmanager)�NamedTemporaryFile)�Any�BinaryIO�Iterator�List�Union�cast)�retry�stop_after_delay� wait_fixed)� get_path_uid)� format_size�path�returnc���tjdksttd��sdStj�|��sJ�d}||kr�tj�|��r^tj��dkr( t|��}n#t$rYdSwxYw|dkStj |tj ��S|tj� |��}}||k��dS)N�win32�geteuidTrF) �sys�platform�hasattr�osr�isabs�lexistsrr�OSError�access�W_OK�dirname)r�previous�path_uids ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/utils/filesystem.py�check_path_ownerr"s��� �|�w���g�b�)�&<�&<���t� �7�=�=�� � ��� ��H� �(� � � �7�?�?�4� � � 9��z�|�|�q� � �!�+�D�1�1�H�H���!�!�!� �5�5�!�����1�}�$��y��r�w�/�/�/�!�2�7�?�?�4�#8�#8�d�H� �(� � � �5s�B� B&�%B&�src�destc��� tj||��dS#t$rC||fD]<} t|��}|rtjd|�d�����-#t$rY�9wxYw�wxYw)z�Wrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. See also https://bugs.python.org/issue37700. �`z ` is a socketN)�shutil�copy2r� is_socket�SpecialFileError)r#r$�f�is_socket_files r!� copy2_fixedr--s��� �� �S�$������� � � � ��t�� H� H�A� H�!*�1���� "�H� �1�2F�a�2F�2F�2F�G�G�G�H�� � � � ��� ���� � ���s+��A&�A�A&� A!�A&� A!�!A&c�X�tjtj|��j��S�N)�stat�S_ISSOCKr�lstat�st_mode�rs r!r)r)Ds�� �=���$���/� 0� 0�0��kwargsc+��K�tddtj�|��tj�|��dd�|��5}t t |��} |V�|���tj|� ����n?#|���tj|� ����wxYw ddd��dS#1swxYwYdS)a%Return a file-like object pointing to a tmp file next to path. The file is created securely and is ensured to be written to disk after the context reaches its end. kwargs will be passed to tempfile.NamedTemporaryFile to control the way the temporary file will be opened. Fz.tmp)�delete�dir�prefix�suffixN�) rrrr�basenamer r�flush�fsync�fileno)rr6r+�results r!�adjacent_tmp_filerBHs0���� � �� �G�O�O�D� !� !��w����%�%��  � � �  � � &� ��h��"�"�� &��L�L�L� �L�L�N�N�N� �H�V�]�]�_�_� %� %� %� %�� �L�L�N�N�N� �H�V�]�]�_�_� %� %� %� %���� %� &� &� &� &� &� &� &� &� &� &� &� &���� &� &� &� &� &� &s*�C1�%B$�);C1�$�>� ��� �g�m�m�D�!�!��  �w�'����y��r�w�'�'�'� !�$� '� '�'r5c����d}d�td��D]�}|d��fd�td��D����z}tj�||��} tj|tjtjztjz��}tj|��tj |��dS#t$rY��t$rYdSwxYwtd ���) N�(accesstest_deleteme_fishfingers_custard_�$abcdefghijklmnopqrstuvwxyz0123456789� �c3�@�K�|]}tj���V��dSr/)�random�choice)�.0�_�alphabets �r!� z)_test_writable_dir_win..�s-�����!L�!L�a�&�-��"9�"9�!L�!L�!L�!L�!L�!Lr5�TFz3Unexpected condition testing for writable directory) �range�joinrr�open�O_RDWR�O_CREAT�O_EXCL�close�unlink�FileExistsError�PermissionErrorr)rr=rWrJ�file�fdrXs @r!rKrK{s���:�H�5�H� �2�Y�Y�����"�'�'�!L�!L�!L�!L�5��8�8�!L�!L�!L�L�L�L���w�|�|�D�$�'�'�� ����r�y�2�:�5�� �A�B�B�B� �H�R�L�L�L� �I�d�O�O�O��4�4��� � � � �D�� � � � �5�5�5�  ���� �G� H� H�Hs�)9C � C'� C'�&C'�patternc���g}tj|��D]<\�}}tj||��}|��fd�|D�����=|S)z�Returns a list of absolute paths of files beneath path, recursively, with filenames which match the UNIX-style shell glob pattern.c3�X�K�|]$}tj��|��V��%dSr/)rrr\)rVr+�roots �r!rYzfind_files..�s3�����=�=��b�g�l�l�4��+�+�=�=�=�=�=�=r5)r�walk�fnmatch�filter�extend)rrgrArW�files�matchesrjs @r!� find_filesrq�sg����F��'�$�-�-�>�>���a���.���0�0��� � �=�=�=�=�W�=�=�=�=�=�=�=� �Mr5c��tj�|��rdStj�|��S)Nr)rr�islink�getsizer4s r!� file_sizeru�s1�� �w�~�~�d�����q� �7�?�?�4� � � r5c�:�tt|����Sr/)rrur4s r!�format_file_sizerw�s�� �y���� '� '�'r5c��d}tj|��D]=\}}}|D]4}tj�||��}|t |��z }�5�>|S)Ng)rrkrr\ru)r�sizerj�_dirsro�filename� file_paths r!�directory_sizer}�si�� �D� �g�d�m�m�)�)���e�U�� )� )�H��� � �T�8�4�4�I� �I�i�(�(� (�D�D� )� �Kr5c�:�tt|����Sr/)rr}r4s r!�format_directory_sizer�s�� �~�d�+�+� ,� ,�,r5)+rlr�os.pathrTr'r0r� contextlibr�tempfiler�typingrrrrr r �pip._vendor.tenacityr r r �pip._internal.utils.compatr�pip._internal.utils.miscr�str�boolr"r-r)rB�_replace_retry�replacerMrKrq�int�floatrurwr}rr<r5r!�r�s������� � � � ����� � � � � � � � � � � � � � � � �%�%�%�%�%�%�'�'�'�'�'�'�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�D�D�D�D�D�D�D�D�D�D�3�3�3�3�3�3�0�0�0�0�0�0��3��4�����6�S���������.1�C�1�D�1�1�1�1��&�C�&�3�&�8�H�3E�&�&�&���&�2��t�*:�*:�1�*=�*=�J�J�t�DT�DT�U�U�U�� �.��� $� $�� (�C�(�D�(�(�(�(�$I��I��I�I�I�I�8�S��3��4��9�����!�C�!�E�#�u�*�-�!�!�!�!�(�3�(�3�(�(�(�(�����s�E�z�!2�����-��-��-�-�-�-�-�-r5