o
    sh|%                     @  s2  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ejd7ddZd8ddZd8ddZd9d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#d<d*d+Z$d=d.d/Z%d0d1d2d3Z&d>d5d6Z'dS )?    )annotationsN)	GeneratorIterator
NamedTupleSequence   )EIClassEIDataELFFileEMachinel      ~ i   i   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   h/var/www/html/construction_image-detection-poc/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_i686-   s   



$r)   archsSequence[str]c                   s>   d|v rt | S d|v rt| S h d t fdd|D S )Narmv7li686>   ppc64s390xx86_64aarch64ppc64leriscv64loongarch64c                 3  s    | ]}| v V  qd S r   r   ).0archallowed_archsr   r   	<genexpr>E   s    z'_have_compatible_abi.<locals>.<genexpr>)r'   r)   any)r   r*   r   r7   r   _have_compatible_abi7   s   	r;   c                   C  s   dS )N2   r   r   r   r   r   <lambda>M   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?   P   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_confstrU   s   
rQ   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_versionrM   c_char_prestype
isinstancer   decode)rS   process_namespacerV   version_strr   r   r   _glibc_version_string_ctypesh   s(   


r]   c                   C  s   t  pt S )z9Returns glibc version string, or None if not using glibc.)rQ   r]   r   r   r   r   _glibc_version_string   s   r^   r\   tuple[int, int]c                 C  sF   t d| }|stjd|  tdd dS t|dt|df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:    )
stacklevelrc   rA   rB   )rematchwarningswarnRuntimeWarningr@   group)r\   mr   r   r   _parse_glibc_version   s   rk   c                  C  s   t  } | d u r	dS t| S )Nrb   )r^   rk   )r\   r   r   r   _get_glibc_version   s   rl   r6   rP   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)
rl   
_manylinuxrT   hasattrrm   r   r?   ro   rq   rs   )r6   rP   	sys_glibcrt   resultr   r   r   _is_compatible   s.   






rx   manylinux2014manylinux2010
manylinux1))r`   rr   )r`   rp   )r`   rn   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 ]J}|D ]E}|j|jkrM|j
}nd}t|j
|dD ]/}t|j|}	d	j|	 }
t||	rp|
 d
| V  |	tv rt|	 }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`      r0   r-      r   rc   zmanylinux_{}_{}rO   )r;   sysr   r?   setrl   rangerA   r>   appendrB   formatrx   _LEGACY_MANYLINUX_MAP)r*   too_old_glibc2current_glibcglibc_max_listglibc_majorglibc_minorr6   	glibc_max	min_minorglibc_versiontag
legacy_tagr   r   r   platform_tags   s:   





r   )r   r   r   r   )r   r   r   r   )r   r   r*   r+   r   r   )r   rG   )r\   r   r   r_   )r   r_   )r6   r   rP   r?   r   r   )r*   r+   r   r|   )(
__future__r   collections
contextlib	functoolsrI   rd   r   rf   typingr   r   r   r   _elffiler   r	   r
   r   r#   r$   r%   contextmanagerr   r'   r)   r;   defaultdictr>   rF   r?   rQ   r]   r^   rk   	lru_cacherl   rx   r   r   r   r   r   r   <module>   s@    



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