a
    qJh|%                     @  sp  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d	d
dddZd	ddddZd	ddddZd	dddddZedd Zded< G dd deZddd d!Zddd"d#Z ddd$d%Z!d	d&d'd(d)Z"ej#d&dd*d+Z$d	ddd,d-d.Z%d/d0d1d2Z&dd3d4d5d6Z'dS )7    )annotationsN)	GeneratorIterator
NamedTupleSequence   )EIClassEIDataELFFileEMachinel      ~ i   i   strz%Generator[ELFFile | None, None, None])pathreturnc              
   c  s\   z8t | d}t|V  W d    n1 s,0    Y  W n tttfyV   d V  Y n0 d S )Nrb)openr
   OSError	TypeError
ValueError)r   f r   F/var/www/shaz/venv/lib/python3.9/site-packages/packaging/_manylinux.py
_parse_elf   s
    ,r   bool)
executabler   c                 C  st   t | X}|d uoP|jtjkoP|jtjkoP|jtj	koP|j
t@ tkoP|j
t@ tkW  d    S 1 sf0    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  sX   t | <}|d uo4|jtjko4|jtjko4|jtj	kW  d    S 1 sJ0    Y  d S r   )
r   r   r   r   r   r	   r   r   r   I386r%   r   r   r   _is_linux_i686-   s    



r(   zSequence[str])r   archsr   c                   s>   d|v rt | S d|v r t| S h d t fdd|D S )Narmv7li686>   s390xx86_64aarch64riscv64loongarch64ppc64ppc64lec                 3  s   | ]}| v V  qd S r   r   ).0archallowed_archsr   r   	<genexpr>E       z'_have_compatible_abi.<locals>.<genexpr>)r&   r(   any)r   r)   r   r5   r   _have_compatible_abi7   s    	r:   c                   C  s   dS )N2   r   r   r   r   r   <lambda>M   r8   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>   z
str | None)r   c                  C  sH   z&t d} | dusJ |  \}}W n ttttfyB   Y dS 0 |S )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    
rO   c                  C  s   zddl } W n ty    Y dS 0 z| d}W n tyD   Y dS 0 z
|j}W n tyd   Y dS 0 | j|_| }t|t	s|
d}|S )zG
    Fallback implementation of glibc_version_string using ctypes.
    r   Nascii)ctypesImportErrorCDLLr   gnu_get_libc_versionrK   c_char_prestype
isinstancer   decode)rQ   process_namespacerT   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.)rO   r[   r   r   r   r   _glibc_version_string   s    r\   ztuple[int, int])rZ   r   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r`   r@   rA   )rematchwarningswarnRuntimeWarningr?   group)rZ   mr   r   r   _parse_glibc_version   s    rh   c                  C  s   t  } | d u rdS t| S )Nr_   )r\   rh   )rZ   r   r   r   _get_glibc_version   s    ri   )r4   rN   r   c                 C  s   t  }||k rdS zdd l}W n ty2   Y dS 0 t|drh||d |d | }|d urdt|S dS |tddkrt|drt|jS |tdd	krt|d
rt|jS |tddkrt|drt|j	S dS )NFr   Tmanylinux_compatibler   r]      manylinux1_compatible   manylinux2010_compatible   manylinux2014_compatible)
ri   
_manylinuxrR   hasattrrj   r   r>   rl   rn   rp   )r4   rN   	sys_glibcrq   resultr   r   r   _is_compatible   s,    






ru   manylinux2014manylinux2010
manylinux1))r]   ro   )r]   rm   )r]   rk   zIterator[str])r)   r   c                 c  s  t tj| sdS tdd}t| ddh@ r4tdd}tt  }|g}t|jd ddD ]}t| }|	t|| qV| D ]}|D ]}|j|jkr|j
}nd}t|j
|dD ]^}t|j|}	d	j|	 }
t||	r|
 d
| V  |	tv rt|	 }t||	r| d
| V  qqqxd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-   r+      r   r`   zmanylinux_{}_{}rM   )r:   sysr   r>   setri   ranger@   r=   appendrA   formatru   _LEGACY_MANYLINUX_MAP)r)   too_old_glibc2current_glibcglibc_max_listglibc_majorglibc_minorr4   	glibc_max	min_minorglibc_versiontag
legacy_tagr   r   r   platform_tags   s0    





r   )(
__future__r   collections
contextlib	functoolsrG   ra   r{   rc   typingr   r   r   r   _elffiler   r	   r
   r   r"   r#   r$   contextmanagerr   r&   r(   r:   defaultdictr=   rE   r>   rO   r[   r\   rh   	lru_cacheri   ru   r   r   r   r   r   r   <module>   s>   
,
