U kf@ @sdZddlmZddlZddlZddlZddlmZddlm Z e rbddlm Z e e ej e fZ dZdZd Zd Zd Zd Zd ZdZdZdZdZdejfdejfdejfdejfdejfdejfdejfgZedejfgZdejfdejfgZdejfdejfdejfdejfdejfgZdejfdejfdejfdejfdejfdejfgZ dejfdejfgZ!dejfdejfd ej"d!fd"ejfd#ejfd$ejfd%ejfd&ejfd'ejfd(ejfdejfg Z#dejfdejfd ej"d!fd"ejfd#ejfd$ejfd%ejfd&ejfd'ejfd(ejfdejfg Z$e!d)ejfd*ejfgZ%e!d+ejfd,ejfd*ejfd-ejfgZ&d.d.d/d0d1Z'dKd2d3d4d5d6d7Z(d8d2d9d:d;Z)dd?Z*dLd2d3d@d5dAdBZ+d.dCdDdEdFZ,dGdd@|d>d@B|d?d@B|d?d@BS)Nl~i)rr r B/opt/hc_python/lib/python3.8/site-packages/wheel/macosx_libfile.pyswap32s    r"rz int | Nonez"tuple[type[ctypes.Structure], int])lib_fileseekrcCs|dkr|}n ||tj|ttjj}|tt t t fkrjt j dkrZtj}ntj}t|}ntj}||||fS)Nlittle)tellr$ctypesc_uint32from_buffer_copyreadsizeofvalue FAT_CIGAM FAT_CIGAM_64MH_CIGAM MH_CIGAM_64sys byteorderZBigEndianStructureZLittleEndianStructurer"Z Structure)r#r$ magic_number BaseClassr r r!get_base_class_and_magic_numbers     r5ztype[ctypes.Structure]Z struct_classr#cCs||t|SN)r)r*r'r+r6r r r! read_datasr8str) path_to_libc st|dvtd\}}|ttttfkr:W5QRdS|ttfkrBGddd|}t|}|tkr|Gddd|nGddd|fdd t|j D}g}|D]`}zDt |j }|dk r|j t krt|d kr|d krWq||Wqtk r YqXqt|dkr2t|W5QRSW5QRdSn.FatHeaderN)__name__ __module__ __qualname__fat_header_fields_fields_r r r r! FatHeader(srAc@seZdZeZdSz2extract_macosx_min_system_version..FatArchN)r<r=r>fat_arch_fieldsr@r r r r!FatArch.srDc@seZdZeZdSrB)r<r=r>fat_arch_64_fieldsr@r r r r!rD3scsg|]}tqSr )r8).0_rDr#r r! 6sz5extract_macosx_min_system_version..) rr)openr5 FAT_MAGIC FAT_MAGIC_64MH_MAGIC MH_MAGIC_64r.r8rangerread_mach_headerrr CPU_TYPE_ARM64lenappend ValueErrormax) r:r4r3rAZ fat_headerZ fat_arch_listZ versions_listelrr rHr!!extract_macosx_min_system_version s>   rYztuple[int, int, int] | NonecCst||\}}|tkrdnd}Gddd|}|dkrHGddd|}nGddd|}t||}t|jD]}|} t||} || | jtkrGdd d |} t| |} t | j S| jt krGd d d |} t| |} t | j S|| | j qlqld S) z This function parses a Mach-O header and extracts information about the minimal macOS version. :param lib_file: reference to opened library file with pointer Z32Z64c@seZdZeZdS)z%read_mach_header..SegmentBaseN)r<r=r>segment_base_fieldsr@r r r r! SegmentBasegsr[c@seZdZeZdSz$read_mach_header..MachHeaderN)r<r=r>mach_header_fieldsr@r r r r! MachHeaderlsr^c@seZdZeZdSr\)r<r=r>mach_header_fields_64r@r r r r!r^qsc@seZdZeZdS)z+read_mach_header..VersionMinCommandN)r<r=r>version_min_command_fieldsr@r r r r!VersionMinCommand{srac@seZdZeZdS)z&read_mach_header..VersionBuildN)r<r=r>build_version_command_fieldsr@r r r r! VersionBuildsrcN)r5rOr8rQr r&r$rLC_VERSION_MIN_MACOSX parse_versionrLC_BUILD_VERSIONrr)r#r$Z base_classr3archr[r^Z mach_headerZ_iposZ segment_basera version_inforcr r r!rRZs*        rRztuple[int, int, int])rrcCs*|d@d?}|d@d?}|d@}|||fS)Nlrrrrr )rryzr r r!res  reStrPath) archive_root platform_tagrc s`|d\}}}tdd|dD}|dd}|ddkrL|ddf}t|dks\td tjkrtd dtjd dD}|dd}|ddkr|ddf}||krtjd d d d|Dd d d|Dn|}t|dkst|i}t |D]~\}}} | D]l} | ds6| drtj || } t| } | dk r| dd} | ddkr|| ddf} | || <qq t|dkrt|t|}d dd|D} |krHfdd|D}d |}t|dkrd}nd}d| d|d|}d tjkr2| d}n | d}tj||d| d|}|S)z Calculate proper macosx platform tag basing on files which are included to wheel Example platform tag `macosx-10.14-x86_64` -css|]}t|VqdSr7rrFrr r r! sz0calculate_macosx_platform_tag...Nr MACOSX_DEPLOYMENT_TARGETcss|]}t|VqdSr7rprqr r r!rrsz[WARNING] MACOSX_DEPLOYMENT_TARGET is set to a lower value ({}) than the version on which the Python interpreter was compiled ({}), and will be ignored. css|]}t|VqdSr7r9rqr r r!rrscss|]}t|VqdSr7rwrqr r r!rrsz.dylibz.sorGcSsg|] }t|qSr rwrqr r r!rIsz1calculate_macosx_platform_tag..csg|]\}}|kr|qSr r )rFkvZ start_versionr r!rIs rJz this filez these 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.)splittuplerTAssertionErrorosenvironr1stderrwriteformatjoinwalkendswithpathrYrWvaluesitems)rmrnprefix base_versionsuffixZ deploy_targetZ versions_dictdirpathZ _dirnames filenamesfilenameZlib_pathZmin_verZfin_base_versionZproblematic_filesZ files_form error_messager rzr!calculate_macosx_platform_tags               r)N)N).__doc__ __future__rr'rr1iortypingrrr9PathLikerlrMr-rNr.rOr/rPr0rdrfrSr(Zc_intr]r_r?rCZc_uint64rErZZc_charZsegment_command_fieldsZsegment_command_fields_64r`rbr"r5r8rYrRrerr r r r!s(        <2