o knh|%@s2UddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z ddlmZmZmZmZdZdZdZejd7d dZd8ddZd8ddZd9ddZeddZded<Gddde Zd:d d!Zd:d"d#Z d:d$d%Z!d;d(d)Z"ej#dd5d6Z'dS)?) annotationsN) GeneratorIterator NamedTupleSequence)EIClassEIDataELFFileEMachinel~iipathstrreturn%Generator[ELFFile | None, None, None]c csbzt|d}t|VWdWdS1swYWdStttfy0dVYdSw)Nrb)openr OSError TypeError ValueError)r fr?/usr/local/lib/python3.10/dist-packages/packaging/_manylinux.py _parse_elfs  & r executableboolcCsvt|-}|duo(|jtjko(|jtjko(|jtj ko(|j t @t ko(|j t @t k WdS1s4wYdSN)rcapacityrC32encodingr Lsbmachiner ArmflagsEF_ARM_ABIMASKEF_ARM_ABI_VER5EF_ARM_ABI_FLOAT_HARDrrrrr_is_linux_armhfs      $r'cCsZt|}|duo|jtjko|jtjko|jtj k WdS1s&wYdSr) rrrrrr rr r I386r&rrr_is_linux_i686-s    $r)archs Sequence[str]cs>d|vrt|Sd|vrt|Shdtfdd|DS)Narmv7li686>ppc64s390xx86_64aarch64ppc64leriscv64 loongarch64c3s|]}|vVqdSrr).0arch allowed_archsrr Esz'_have_compatible_abi..)r'r)any)rr*rr7r_have_compatible_abi7s  r;cCsdS)N2rrrrrMsr=zdict[int, int]_LAST_GLIBC_MINORc@seZdZUded<ded<dS) _GLibCVersionintmajorminorN)__name__ __module__ __qualname____annotations__rrrrr?Ps  r? str | Nonec CsFztd}|dus J|\}}W|Sttttfy"YdSw)zJ Primary implementation of glibc_version_string using os.confstr. CS_GNU_LIBC_VERSIONN)osconfstrrsplitAssertionErrorAttributeErrorrr)version_string_versionrrr_glibc_version_string_confstrUs  rQcCszddl}Wn tyYdSwz|d}Wn ty"YdSwz|j}Wn ty2YdSw|j|_|}t|t sD| d}|S)zG Fallback implementation of glibc_version_string using ctypes. rNascii) ctypes ImportErrorCDLLrgnu_get_libc_versionrMc_char_prestype isinstancer decode)rSprocess_namespacerV version_strrrr_glibc_version_string_ctypeshs(       r]cCs tptS)z9Returns glibc version string, or None if not using glibc.)rQr]rrrr_glibc_version_strings r^r\tuple[int, int]cCsFtd|}|stjd|tdddSt|dt|dfS)a3Parse glibc version. We use a regexp instead of str.split because we want to discard any random junk that might come after the minor version -- this might happen in patched/forked versions of glibc (e.g. Linaro's version of glibc uses version strings like "2.20-2014.11"). See gh-3588. z$(?P[0-9]+)\.(?P[0-9]+)z;Expected glibc version with 2 components major.minor, got: ) stacklevelrcrArB)rematchwarningswarnRuntimeWarningr@group)r\mrrr_parse_glibc_versions rkcCst}|dur dSt|S)Nrb)r^rk)r\rrr_get_glibc_versionsrlr6rPcCst}||kr dSzddl}Wn tyYdSwt|dr4||d|d|}|dur2t|SdS|tddkrEt|drEt|jS|tdd krVt|d rVt|jS|tdd krgt|d rgt|j SdS) NFrTmanylinux_compatiblerr`manylinux1_compatible manylinux2010_compatiblemanylinux2014_compatible) rl _manylinuxrThasattrrmrr?rorqrs)r6rP sys_glibcrtresultrrr_is_compatibles.         rx manylinux2014 manylinux2010 manylinux1))r`rr)r`rp)r`rn Iterator[str]c csttj|s dStdd}t|ddh@rtdd}tt}|g}t|jdddD]}t|}| t||q,|D]J}|D]E}|j|jkrM|j }nd}t|j |dD]/}t|j|} d j | } t || rp| d |V| t vrt | } t || r| d |VqVqAq=dS) aGenerate manylinux tags compatible to the current platform. :param archs: Sequence of compatible architectures. The first one shall be the closest to the actual architecture and be the part of platform tag after the ``linux_`` prefix, e.g. ``x86_64``. The ``linux_`` prefix is assumed as a prerequisite for the current platform to be manylinux-compatible. :returns: An iterator of compatible manylinux tags. Nr`r0r-rrczmanylinux_{}_{}rO)r;sysrr?setrlrangerAr>appendrBformatrx_LEGACY_MANYLINUX_MAP) r*too_old_glibc2 current_glibcglibc_max_list glibc_major glibc_minorr6 glibc_max min_minor glibc_versiontag legacy_tagrrr platform_tagss:         r)r r rr)rr rr)rr r*r+rr)rrG)r\r rr_)rr_)r6r rPr?rr)r*r+rr|)( __future__r collections contextlib functoolsrIrdrrftypingrrrr_elffilerr r r r#r$r%contextmanagerrr'r)r; defaultdictr>rFr?rQr]r^rk lru_cacherlrxrrrrrrs@       ,