o
    )riW%                     @  sX  U d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
mZmZmZ ddlmZmZmZmZ dZdZdZh d	Zejd<ddZd=ddZd=ddZd>ddZedd Zded< G dd deZd?d!d"Z d?d#d$Z!d?d%d&Z"d@d(d)Z#ej$dAd*d+Z%dBd.d/Z&ed0d1d2ed0d3d4ed0d5d6iZ'd7ed8< dCd:d;Z(dS )D    )annotationsN)	GeneratorIterator
NamedTupleSequence   )EIClassEIDataELFFileEMachinel      ~ i   i   >   ppc64s390xx86_64aarch64ppc64leriscv64loongarch64pathstrreturn%Generator[ELFFile | None, None, None]c              
   c  sb    zt | d}t|V  W d    W d S 1 sw   Y  W d S  tttfy0   d V  Y d S w )Nrb)openr
   OSError	TypeError
ValueError)r   f r   S/home/air/biblejyuku/back/venv/lib/python3.10/site-packages/packaging/_manylinux.py
_parse_elf   s   &r   
executableboolc                 C  sv   t | -}|d uo(|jtjko(|jtjko(|jtj	ko(|j
t@ tko(|j
t@ tk	 W  d    S 1 s4w   Y  d S N)r   capacityr   C32encodingr	   Lsbmachiner   ArmflagsEF_ARM_ABIMASKEF_ARM_ABI_VER5EF_ARM_ABI_FLOAT_HARDr    r   r   r   r   _is_linux_armhf(   s   



$r.   c                 C  sZ   t | }|d uo|jtjko|jtjko|jtj	k	 W  d    S 1 s&w   Y  d S r"   )
r   r#   r   r$   r%   r	   r&   r'   r   I386r-   r   r   r   _is_linux_i6867   s   



$r0   archsSequence[str]c                 C  s2   d|v rt | S d|v rt| S tdd |D S )Narmv7li686c                 s  s    | ]}|t v V  qd S r"   )_ALLOWED_ARCHS).0archr   r   r   	<genexpr>F   s    z'_have_compatible_abi.<locals>.<genexpr>)r.   r0   any)r    r1   r   r   r   _have_compatible_abiA   s
   r:   c                   C  s   dS )N2   r   r   r   r   r   <lambda>N   s    r<   zdict[int, int]_LAST_GLIBC_MINORc                   @  s   e Zd ZU ded< ded< dS )_GLibCVersionintmajorminorN)__name__
__module____qualname____annotations__r   r   r   r   r>   Q   s   
 r>   
str | Nonec                  C  sF   zt d} | dusJ |  \}}W |S  ttttfy"   Y dS w )zJ
    Primary implementation of glibc_version_string using os.confstr.
    CS_GNU_LIBC_VERSIONN)osconfstrrsplitAssertionErrorAttributeErrorr   r   )version_string_versionr   r   r   _glibc_version_string_confstrV   s   
rP   c                  C  s   zddl } W n
 ty   Y dS w z| d}W n
 ty"   Y dS w z|j}W n
 ty2   Y dS w | j|_| }t|t	sD|
d}|S )zG
    Fallback implementation of glibc_version_string using ctypes.
    r   Nascii)ctypesImportErrorCDLLr   gnu_get_libc_versionrL   c_char_prestype
isinstancer   decode)rR   process_namespacerU   version_strr   r   r   _glibc_version_string_ctypesi   s(   


r\   c                   C  s   t  pt S )z9Returns glibc version string, or None if not using glibc.)rP   r\   r   r   r   r   _glibc_version_string   s   r]   r[   c                 C  sN   t d| }|stjd|  tdd tddS tt|dt|dS )a3  Parse 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<major>[0-9]+)\.(?P<minor>[0-9]+)z;Expected glibc version with 2 components major.minor, got:    )
stacklevelr@   rA   )rematchwarningswarnRuntimeWarningr>   r?   group)r[   mr   r   r   _parse_glibc_version   s   
rh   c                  C  s    t  } | d u rtddS t| S )Nr`   )r]   r>   rh   )r[   r   r   r   _get_glibc_version   s   
ri   r7   rO   c                 C  s   t  }||k r	dS zdd l}W n
 ty   Y dS w t|dr4||d |d | }|d ur2t|S dS |tddkrEt|drEt|jS |tdd	krVt|d
rVt|jS |tddkrgt|drgt|j	S dS )NFr   Tmanylinux_compatibler   r^      manylinux1_compatible   manylinux2010_compatible   manylinux2014_compatible)
ri   
_manylinuxrS   hasattrrj   r!   r>   rl   rn   rp   )r7   rO   	sys_glibcrq   resultr   r   r   _is_compatible   s0   



ru   r^   ro   manylinux2014rm   manylinux2010rk   
manylinux1zdict[_GLibCVersion, str]_LEGACY_MANYLINUX_MAPIterator[str]c                 c  s   t tj| s	dS tdd}t| ddh@ rtdd}tt  }|g}t|jd ddD ]}t| }|	t|| q,| D ]B}|D ]=}|j|jkrM|j
}nd}t|j
|dD ]'}t|j|}	t||	r}d	jg |	|R  V  t|	 }
r}|
 d
| V  qVqAq=dS )a  Generate 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^      r   r4      r   r`   zmanylinux_{}_{}_{}rN   )r:   sysr    r>   setri   ranger@   r=   appendrA   ru   formatry   get)r1   too_old_glibc2current_glibcglibc_max_listglibc_majorglibc_minorr7   	glibc_max	min_minorglibc_version
legacy_tagr   r   r   platform_tags   s4   



r   )r   r   r   r   )r    r   r   r!   )r    r   r1   r2   r   r!   )r   rF   )r[   r   r   r>   )r   r>   )r7   r   rO   r>   r   r!   )r1   r2   r   rz   ))
__future__r   collections
contextlib	functoolsrH   ra   r}   rc   typingr   r   r   r   _elffiler   r	   r
   r   r*   r+   r,   r5   contextmanagerr   r.   r0   r:   defaultdictr=   rE   r>   rP   r\   r]   rh   	lru_cacheri   ru   ry   r   r   r   r   r   <module>   sB    






,





