HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/wheel/__pycache__/macosx_libfile.cpython-38.pyc
U

�-^R.�@sHdZddlZddlZdZdZdZdZdZdZd	Z	d
Z
dZdZd
ej
fdejfdejfdej
fdej
fdej
fdej
fgZedej
fgZd
ej
fdej
fgZdejfdejfdej
fdej
fdej
fgZdejfdejfdejfdejfdej
fdej
fgZdej
fdej
fgZdej
fdej
fdejdfdej
fdej
fdej
fd ej
fd!ejfd"ejfd#ej
fdej
fgZdej
fdej
fdejdfdejfdejfdejfd ejfd!ejfd"ejfd#ej
fdej
fgZed$ej
fd%ej
fgZed&ej
fd'ej
fd%ej
fd(ej
fgZd)d*�Zd5d+d,�Zd-d.�Zd/d0�Zd6d1d2�Zd3d4�Z dS)7a	
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 builded 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.
�Nl�:�l�~u}l�:�l�~ul�z�}l�m�l�z�}l�m��$�2�magicZcputypeZ
cpusubtypeZfiletype�ncmdsZ
sizeofcmds�flagsZreserved�	nfat_arch�offset�sizeZalign�cmd�cmdsizeZsegname�ZvmaddrZvmsizeZfileoffZfilesizeZmaxprotZinitprotZnsects�versionZsdk�platform�minosZntoolscCs0|d>d@|d>d@B|d?d@B|d?d@BS)N�l~�i�����)�xrr�6/usr/lib/python3/dist-packages/wheel/macosx_libfile.py�swap32�s

�
�
�rcCs�|dkr|��}n
|�|�tj�|�t�tj���j}|tt	t
tfkrjtj
dkrZtj}ntj}t|�}ntj}|�|�||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�	byteorderZBigEndianStructureZLittleEndianStructurerZ	Structure)�lib_filer�magic_number�	BaseClassrrr�get_base_class_and_magic_number�s

�


r*cCs|�|�t�|���S)N)rrrr)Zstruct_classr'rrr�	read_data�s�r+c	
sht|d���R�t�d�\}}|ttttfkr:W5QR�dS|ttfk�rGdd�d|�}t|��}|tkr|Gdd�d|��nGdd�d|����fdd	�t|j	�D�}g}|D]<}z"t
�|j�}|dk	r�|�|�Wq�t
k
r�Yq�Xq�t|�dk�rt|�W5QR�SW5QR�dSn<zt
�d�WW5QR�St
k
�rXYW5QR�dSXW5QRXdS)
N�rbrc@seZdZeZdS)z4extract_macosx_min_system_version.<locals>.FatHeaderN)�__name__�
__module__�__qualname__�fat_header_fields�_fields_rrrr�	FatHeader�sr2c@seZdZeZdS�z2extract_macosx_min_system_version.<locals>.FatArchN)r-r.r/�fat_arch_fieldsr1rrrr�FatArchsr5c@seZdZeZdSr3)r-r.r/�fat_arch_64_fieldsr1rrrrr5scsg|]}t����qSr)r+)�.0�_�r5r'rr�
<listcomp>
sz5extract_macosx_min_system_version.<locals>.<listcomp>)�openr*�	FAT_MAGIC�FAT_MAGIC_64�MH_MAGIC�MH_MAGIC_64r"r+�ranger�read_mach_headerr�append�
ValueError�len�max)	Zpath_to_libr)r(r2Z
fat_headerZ
fat_arch_listZ
versions_listZelr
rr9r�!extract_macosx_min_system_version�s4
rFcCs|dk	r|�|�t|�\}}|tkr*dnd}Gdd�d|�}|dkrXGdd�d|�}nGdd�d|�}t||�}t|j�D]�}|��}	t||�}
|�|	�|
jtkr�Gd	d
�d
|�}t||�}t	|j
�S|
jtk�rGdd�d|�}
t|
|�}t	|j�S|�|	|
j
�q|q|dS)
z�
    This funcition parse mach-O header and extract
    information about minimal system version

    :param lib_file: reference to opened library file with pointer
    NZ32Z64c@seZdZeZdS)z%read_mach_header.<locals>.SegmentBaseN)r-r.r/�segment_base_fieldsr1rrrr�SegmentBase.srHc@seZdZeZdS�z$read_mach_header.<locals>.MachHeaderN)r-r.r/�mach_header_fieldsr1rrrr�
MachHeader3srKc@seZdZeZdSrI)r-r.r/�mach_header_fields_64r1rrrrrK8sc@seZdZeZdS)z+read_mach_header.<locals>.VersionMinCommandN)r-r.r/�version_min_command_fieldsr1rrrr�VersionMinCommandAsrNc@seZdZeZdS)z&read_mach_header.<locals>.VersionBuildN)r-r.r/�build_version_command_fieldsr1rrrr�VersionBuildGsrP)rr*r>r+r@rrr
�LC_VERSION_MIN_MACOSX�
parse_versionr
�LC_BUILD_VERSIONrr)r'rZ
base_classr(ZarchrHrKZmach_headerZ_i�posZsegment_baserN�version_inforPrrrrA"s.






rAcCs*|d@d?}|d@d?}|d@}|||fS)Nl�rrrrr)r
r�y�zrrrrRQsrR)N)N)!�__doc__rr%r<r!r=r"r>r#r?r$rQrSrZc_intrJrLr0r4Zc_uint64r6rGZc_charZsegment_command_fieldsZsegment_command_fields_64rMrOrr*r+rFrArRrrrr�<module>s�%�	�������
,
/