Current File : //proc/self/root/lib/python3/dist-packages/wheel/__pycache__/macosx_libfile.cpython-312.pyc
�

C�e?���dZddlmZddlZddlZddlZ	dZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdej"fdej$fdej$fdej"fdej"fdej"fdej"fgZ	edej"fgzZ	dej"fdej"fgZ	dej$fdej$fdej"fdej"fdej"fgZ	dej$fdej$fdej.fdej.fdej"fdej"fgZ	dej"fdej"fgZ	dej"fdej"fdej4dzfdej"fd ej"fd!ej"fd"ej"fd#ej$fd$ej$fd%ej"fdej"fgZ	dej"fdej"fdej4dzfdej.fd ej.fd!ej.fd"ej.fd#ej$fd$ej$fd%ej"fdej"fgZ	ed&ej"fd'ej"fgzZ	ed(ej"fd)ej"fd'ej"fd*ej"fgzZ	d+�Zd2d,�Z d-�Z!d.�Z"d2d/�Z#d0�Z$d1�Z%y)3a�
This module contains function to analyse dynamic library
headers to extract system information

Currently only for MacOSX

Library file on macosx system starts with Mach-O or Fat field.
This can be distinguish by first 32 bites and it is called magic number.
Proper value of magic number is with suffix _MAGIC. Suffix _CIGAM means
reversed bytes order.
Both fields can occur in two types: 32 and 64 bytes.

FAT field inform that this library contains few version of library
(typically for different types version). It contains
information where Mach-O headers starts.

Each section started with Mach-O header contains one library
(So if file starts with this field it contains only one version).

After filed Mach-O there are section fields.
Each of them starts with two fields:
cmd - magic number for this command
cmdsize - total size occupied by this section information.

In this case only sections LC_VERSION_MIN_MACOSX (for macosx 10.13 and earlier)
and LC_BUILD_VERSION (for macosx 10.14 and newer) are interesting,
because them contains information about minimal system version.

Important remarks:
- For fat files this implementation looks for maximum number version.
  It not check if it is 32 or 64 and do not compare it with currently built package.
  So it is possible to false report higher version that needed.
- All structures signatures are taken form macosx header files.
- I think that binary format will be more stable than `otool` output.
  and if apple introduce some changes both implementation will need to be updated.
- The system compile will set the deployment target no lower than
  11.0 for arm64 builds. For "Universal 2" builds use the x86_64 deployment
  target when the arm64 target is 11.0.
�)�annotationsNl�:�l�~u}l�:�l�~ul�z�}l�m�l�z�}l�m��$�2i�magic�cputype�
cpusubtype�filetype�ncmds�
sizeofcmds�flags�reserved�	nfat_arch�offset�size�align�cmd�cmdsize�segname��vmaddr�vmsize�fileoff�filesize�maxprot�initprot�nsects�version�sdk�platform�minos�ntoolsc�H�|dzdz|dzdzz|dz	dzz|dz	dzzS)N�l~�i�����)�xs �6/usr/lib/python3/dist-packages/wheel/macosx_libfile.py�swap32r*�sH��
�r�'�Z�	�
��F�j� �	"�
��F�j� �	"�
��G�z�!�	#��c��|�|j�}n|j|�tjj	|jtjtj���j}|ttttfvr@tjdk(rtj}ntj}t!|�}ntj"}|j|�||fS)N�little)�tell�seek�ctypes�c_uint32�from_buffer_copy�read�sizeof�value�	FAT_CIGAM�FAT_CIGAM_64�MH_CIGAM�MH_CIGAM_64�sys�	byteorder�BigEndianStructure�LittleEndianStructurer*�	Structure)�lib_filer/�magic_number�	BaseClasss    r)�get_base_class_and_magic_numberrB�s����|��}�}����
�
�d���?�?�3�3��
�
�f�m�m�F�O�O�4�5���e��
�	�<��;�G�G��=�=�H�$��1�1�I��4�4�I��l�+���$�$�	��M�M�$���l�"�"r+c�h�|j|jtj|���S�N)r2r3r0r4)�struct_classr?s  r)�	read_datarFs%���(�(����v�}�}�\�7R�)S�T�Tr+c��t|d�5}t|d�\}}|tttt
fvr
	ddd�y|ttfvr�Gd�d|�}t||�}|tk(rGd�d|�}nGd�d|�}t|j�D�cgc]}t||���}}g}	|D]S}
	t||
j�}|�8|
jtk(rt|�dk7r|d	k(r�C|	j|��Ut|	�dkDrt#|	�cddd�S	ddd�y	t|d�cddd�Scc}w#t $rY��wxYw#t $r	Yddd�ywxYw#1swYyxYw)
N�rbrc��eZdZeZy)�4extract_macosx_min_system_version.<locals>.FatHeaderN)�__name__�
__module__�__qualname__�fat_header_fields�_fields_r'r+r)�	FatHeaderrJs��,�r+rPc��eZdZeZy��2extract_macosx_min_system_version.<locals>.FatArchN)rKrLrM�fat_arch_fieldsrOr'r+r)�FatArchrS$s��.�Hr+rUc��eZdZeZyrR)rKrLrM�fat_arch_64_fieldsrOr'r+r)rUz2extract_macosx_min_system_version.<locals>.FatArch)s��1�Hr+�)�rr)�openrB�	FAT_MAGIC�FAT_MAGIC_64�MH_MAGIC�MH_MAGIC_64r7rF�ranger�read_mach_headerrr�CPU_TYPE_ARM64�len�append�
ValueError�max)�path_to_libr?rAr@rP�
fat_headerrU�_�
fat_arch_list�
versions_list�elrs            r)�!extract_macosx_min_system_versionrls���	
�k�4�	 �6�H�"A�(�A�"N��	�<��	�<��;�O�O��6�6�
�I�|�4�4�
-�I�
-�#�9�h�7�J��y�(�/�i�/�
2�i�2�7<�J�<P�<P�6Q��12�	�'�8�,��M���M�#�
���.�x����C�G��*��:�:��7�C�
�<N�RS�<S� '�*�4� (�%�,�,�W�5��
�$�=�!�A�%��=�)�[6�6�^�_6�6�d
�'��!�4�g6�6��*��("������
�?��m6�6�h
��i6�6�sw�)E8�AE8�E�.	E8�8>E�6E8�7E�E8�,E8�7E �E8�	E�E8�E�E8� 
E5�*E8�4E5�5E8�8Fc��|�|j|�t|�\}}|tk(rdnd}Gd�d|�}|dk(rGd�d|�}nGd�d|�}t||�}t	|j
�D]�}|j
�}	t||�}
|j|	�|
jtk(r.Gd	�d
|�}t||�}t|j�cS|
jtk(r.Gd�d|�}
t|
|�}t|j�cS|j|	|
jz���y)
z�
    This funcition parse mach-O header and extract
    information about minimal system version

    :param lib_file: reference to opened library file with pointer
    N�32�64c��eZdZeZy)�%read_mach_header.<locals>.SegmentBaseN)rKrLrM�segment_base_fieldsrOr'r+r)�SegmentBaserq\s��&�r+rsc��eZdZeZy��$read_mach_header.<locals>.MachHeaderN)rKrLrM�mach_header_fieldsrOr'r+r)�
MachHeaderrvas��)�Hr+rxc��eZdZeZyru)rKrLrM�mach_header_fields_64rOr'r+r)rxz$read_mach_header.<locals>.MachHeaderfs��,�Hr+c��eZdZeZy)�+read_mach_header.<locals>.VersionMinCommandN)rKrLrM�version_min_command_fieldsrOr'r+r)�VersionMinCommandr|ps��5�r+r~c��eZdZeZy)�&read_mach_header.<locals>.VersionBuildN)rKrLrM�build_version_command_fieldsrOr'r+r)�VersionBuildr�ws��7�r+r�)r/rBr]rFr_r
r.r�LC_VERSION_MIN_MACOSX�
parse_versionr�LC_BUILD_VERSIONr r)r?r/�
base_classr@�archrsrx�mach_header�_i�pos�segment_baser~�version_infor�s              r)r`r`Ps:�����
�
�d��>�x�H��J���8�+�4��D�'�j�'��t�|�	*��	*�
	-��	-��J��1�K��K�%�%�&����m�m�o�� ��h�7���
�
�c�����4�4�
6�J�
6�%�%6��A�L� ��!5�!5�6�6�
�
�
�!1�
1�
8�z�
8�%�\�8�<�L� ��!3�!3�4�4��M�M�#�� 4� 4�4�5��)r+c�6�|dzdz	}|dzdz	}|dz}|||fS)Nl�rr%r$r&r')rr(�y�zs    r)r�r��s5��	�:�	�"�$�A�	�:�	�!�#�A��*��A��a��7�Nr+c	���|jd�\}}}td�|jd�D��}|dd}|ddkDr|ddf}t|�dk(sJ�dtjvr�td	�tjdjd�D��}|dd}|ddkDr|ddf}||kr\t
jjd
jdjd�|D��djd�|D����n|}t|�dk(sJ�|}i}tj|�D]w\}}	}
|
D]l}|jd
�s|jd�s�&tjj||�}t|�}
|
��T|
dd}
|
ddkDr|
ddf}
|
||<�n�yt|�dkDr#t|t|j���}dj|D�cgc]
}t!|���c}�}||kr�|j#�D��cgc]
\}}||kDs�|��}}}dj|�}t|�dk(rd}nd}d|zdz|zdz|z}dtjvr|jd�}n|jd�}t
jj|�|dz|zdz|z}|Scc}wcc}}w)z�
    Calculate proper macosx platform tag basing on files which are included to wheel

    Example platform tag `macosx-10.14-x86_64`
    �-c3�2K�|]}t|����y�wrD��int��.0r(s  r)�	<genexpr>z0calculate_macosx_platform_tag.<locals>.<genexpr>�s����A�A��Q��A����.N�r�
�MACOSX_DEPLOYMENT_TARGETc3�2K�|]}t|����y�wrDr�r�s  r)r�z0calculate_macosx_platform_tag.<locals>.<genexpr>�s����
��C��F�
�r�z�[WARNING] MACOSX_DEPLOYMENT_TARGET is set to a lower value ({}) than the version on which the Python interpreter was compiled ({}), and will be ignored.
c3�2K�|]}t|����y�wrD��strr�s  r)r�z0calculate_macosx_platform_tag.<locals>.<genexpr>�s����;��S��V�;�r�c3�2K�|]}t|����y�wrDr�r�s  r)r�z0calculate_macosx_platform_tag.<locals>.<genexpr>�s����:��S��V�:�r�z.dylibz.sorh�
rXz	this filezthese filesz}[WARNING] This wheel needs a higher macOS version than {}  To silence this warning, set MACOSX_DEPLOYMENT_TARGET to at least z
 or recreate z( with lower MACOSX_DEPLOYMENT_TARGET:  
z,is set in MACOSX_DEPLOYMENT_TARGET variable.z8the version your Python interpreter is compiled against.)�split�tuplerb�os�environr:�stderr�write�format�join�walk�endswith�pathrlre�valuesr��items)�archive_root�platform_tag�prefix�base_version�suffix�
deploy_target�
start_version�
versions_dict�dirpath�	_dirnames�	filenames�filename�lib_path�min_verr(�fin_base_version�k�v�problematic_files�
files_form�
error_messages                     r)�calculate_macosx_platform_tagr��s+��$0�#5�#5�c�#:� �F�L�&��A��);�);�C�)@�A�A�L����#�L��A����$�Q���+���|���!�!�!�!�R�Z�Z�/��
��J�J�'A�B�H�H��M�
�
�
�&�b�q�)�
����b� �*�1�-�q�1�M��<�'��J�J���%�%+�V��H�H�;�]�;�;��H�H�:�\�:�:�&�
�)�L��|���!�!�!� �M��M�)+����)>�	6�%���I�!�	6�H�� � ��*�h�.?�.?��.F��7�7�<�<���:��;�H�E���&�%�a��l�G��q�z�B��#*�1�:�q�/��.5�M�(�+�	6�	6��=��A���<��]�-A�-A�-C�)D�E���x�x�� >�A��Q�� >�?���|�#�+8�+>�+>�+@�V�4�1�a�A�
�DU�Q�V��V� �I�I�&7�8��� �!�Q�&�$�J�&�J�
Q��
��
��	
�
,�
,�/@�

@�	�&����3�)�0�0�>��M�*�0�0�J��M�	�
�
����'��C�<�"2�2�S�8�6�A�L����=!?��Vs�9K�*
K�8KrD)&�__doc__�
__future__rr0r�r:r[r6r\r7r]r8r^r9r�r�rar1�c_intrwrzrNrT�c_uint64rWrr�c_char�segment_command_fields�segment_command_fields_64r}r�r*rBrFrlr`r�r�r'r+r)�<module>r�s���&�P#�
�	�
�?��	��	�������������������
�f�o�o��������6�<�<� �����!��f�o�o���6�?�?�#��f�o�o�����+�z�6�?�?�.K�-L�L����v���/�+�v���1O�P���������6�<�<� �
�v�����V�_�_���f�o�o�����������6�<�<� �
�v�����V�_�_���f�o�o������!�
��	��v���/�)�V�_�_�1M�N��#��F�O�O������ ���
�
��"�#�
�v����
�v�������� �����!�����������
�v�����f�o�o�����$�F�O�O������ ���
�
��"�#�
�v����
�v�������� �����!�����������
�v�����f�o�o����� 1����� �
�F�O�O��4���
� 3�����!��f�o�o��
�F�O�O��
�v����	6� ��
��#�0U�7�t.�b�Or+