Edc @sidZddlZddlZddlZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdejfdejfdejfdejfdejfdejfdejfgZedejfgZdejfdejfgZdejfdejfdejfdejfdejfgZdejfdejfdejfdejfdejfdejfgZdejfdejfgZdejfdejfdejdfdejfdejfd ejfd!ejfd"ejfd#ejfd$ejfdejfg Zdejfdejfdejdfdejfdejfd ejfd!ejfd"ejfd#ejfd$ejfdejfg Zed%ejfd&ejfgZed'ejfd(ejfd&ejfd)ejfgZd*Zdd+Zd,Z d-Z!dd.Z"d/Z#d0Z$dS(1s 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. iNIIIIIIIIi$i2i tmagictcputypet cpusubtypetfiletypetncmdst sizeofcmdstflagstreservedt nfat_archtoffsettsizetaligntcmdtcmdsizetsegnameitvmaddrtvmsizetfileofftfilesizetmaxprottinitprottnsectstversiontsdktplatformtminostntoolscCs0|d>d@|d>d@B|d?d@B|d?d@BS(NiIiiii((tx((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pytswap32s#cCs|dkr|j}n |j|tjj|jtjtjj}|t t t t gkrt jdkrtj}n tj}t|}n tj}|j|||fS(Ntlittle(tNonettelltseektctypestc_uint32tfrom_buffer_copytreadtsizeoftvaluet FAT_CIGAMt FAT_CIGAM_64tMH_CIGAMt MH_CIGAM_64tsyst byteordertBigEndianStructuretLittleEndianStructureRt Structure(tlib_fileR t magic_numbert BaseClass((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pytget_base_class_and_magic_numbers   !    cCs|j|jtj|S(N(R#R$R!R%(t struct_classR0((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyt read_datas c Cst|d}t|d\}}|ttttgkrCdS|ttgkrd|fdY}t||}|tkrd|fdY}nd|fdY}gt|j D]}t||^q}g} x|D]} yht || j } | dk rZ| j tkrJt|dkrJ| d krJwqJn| j| nWqtk rnqXqWt| dkrt| SdSn&yt |dSWntk rdSXWdQXdS( Ntrbit FatHeadercBseZeZRS((t__name__t __module__tfat_header_fieldst_fields_(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyR7stFatArchcBseZeZRS((R8R9tfat_arch_fieldsR;(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyR<scBseZeZRS((R8R9tfat_arch_64_fieldsR;(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyR< sii (i ii(topenR3t FAT_MAGICt FAT_MAGIC_64tMH_MAGICt MH_MAGIC_64R(R5trangeRtread_mach_headerR RRtCPU_TYPE_ARM64tlentappendt ValueErrortmax( t path_to_libR0R2R1R7t fat_headerR<t_t fat_arch_listt versions_listtelR((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyt!extract_macosx_min_system_versions: +  !     cCs|d k r|j|nt|\}}|tkr@dnd}d|fdY}|dkrd|fdY}nd|fdY}t||}xt|jD]}|j} t||} |j| | jt kr%d|fd Y} t| |} t | j S| jt krfd |fd Y} t| |} t | j S|j| | jqqWd S( s This funcition parse mach-O header and extract information about minimal system version :param lib_file: reference to opened library file with pointer t32t64t SegmentBasecBseZeZRS((R8R9tsegment_base_fieldsR;(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyRT=st MachHeadercBseZeZRS((R8R9tmach_header_fieldsR;(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyRVBscBseZeZRS((R8R9tmach_header_fields_64R;(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyRVGstVersionMinCommandcBseZeZRS((R8R9tversion_min_command_fieldsR;(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyRYPst VersionBuildcBseZeZRS((R8R9tbuild_version_command_fieldsR;(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyR[VsN(RR R3RBR5RDRRR tLC_VERSION_MIN_MACOSXt parse_versionRtLC_BUILD_VERSIONRR (R0R t base_classR1tarchRTRVt mach_headert_itpost segment_baseRYt version_infoR[((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyRE1s.      cCs3|d@d?}|d@d?}|d@}|||fS(NIiiii((RRtytz((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyR^`s cCsu|jd\}}}tg|jdD]}t|^q+}|d }|ddkrs|ddf}nt|dkstdtjkrVtgtjdjdD]}t|^q}|d }|ddkr|ddf}n||krMtjj dj dj d|Ddj d |DqV|}nt|dksnt|}i}xtj |D]\} } } x| D]} | j d s| j d rtjj | | } t| }|dk r1|dd!}|ddkr!|ddf}n||| }scss|]}t|VqdS(N(Rl(RmR((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pys ~ss.dylibs.soRMs is this files these filess}[WARNING] This wheel needs a higher macOS version than {} To silence this warning, set MACOSX_DEPLOYMENT_TARGET to at least s or recreate s( with lower MACOSX_DEPLOYMENT_TARGET: s,is set in MACOSX_DEPLOYMENT_TARGET variable.s8the version your Python interpreter is compiled against.N(tsplitttupletintRGtAssertionErrortostenvironR+tstderrtwritetformattjointwalktendswithtpathRQRRJtvaluesRltitems(t archive_roott platform_tagtprefixt base_versiontsuffixRt deploy_targett start_versiont versions_dicttdirpathtdirnamest filenamestfilenametlib_pathtmin_vertfin_base_versiontktvtproblematic_filest files_formt error_message((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pytcalculate_macosx_platform_taggs`.  )         ( 1  (%t__doc__R!RrR+R@R'RAR(RBR)RCR*R]R_RFR"tc_intRWRXR:R=tc_uint64R>RUtc_chartsegment_command_fieldstsegment_command_fields_64RZR\RRR3R5RQRER^R(((s8/usr/lib/python2.7/site-packages/wheel/macosx_libfile.pyt'sf           6 /