a
    0fr%                     @  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   Y/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pip/_vendor/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   Z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   Z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>   aarch64Zloongarch64s390xppc64leZriscv64ppc64x86_64c                 3  s   | ]}| v V  qd S r   r   ).0archZallowed_archsr   r   	<genexpr>E       z'_have_compatible_abi.<locals>.<genexpr>)r%   r&   any)r   r'   r   r1   r   _have_compatible_abi7   s    	r5   c                   C  s   dS )N2   r   r   r   r   r   <lambda>M   r3   r7   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   r9   P   s   
r9   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    
rJ   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_versionrF   c_char_prestype
isinstancer   decode)rL   process_namespacerO   version_strr   r   r   _glibc_version_string_ctypesh   s"    


rV   c                   C  s   t  p
t S )z9Returns glibc version string, or None if not using glibc.)rJ   rV   r   r   r   r   _glibc_version_string   s    rW   ztuple[int, int])rU   r   c                 C  sB   t d| }|s&td|  t 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: rY   r;   r<   )rematchwarningswarnRuntimeWarningr:   group)rU   mr   r   r   _parse_glibc_version   s    ra   c                  C  s   t  } | d u rdS t| S )NrX   )rW   ra   )rU   r   r   r   _get_glibc_version   s    rb   )r0   rI   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         manylinux1_compatible   manylinux2010_compatible   manylinux2014_compatible)
rb   
_manylinuxrM   hasattrrc   r   r9   rf   rh   rj   )r0   rI   	sys_glibcrk   resultr   r   r   _is_compatible   s,    






ro   manylinux2014manylinux2010
manylinux1))rd   ri   )rd   rg   )rd   re   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.
    Nrd      r.   r)      r   rY   zmanylinux_{}_{}rH   )r5   sysr   r9   setrb   ranger;   r8   appendr<   formatro   _LEGACY_MANYLINUX_MAP)r'   too_old_glibc2current_glibcglibc_max_listglibc_majorglibc_minorr0   	glibc_max	min_minorglibc_versiontag
legacy_tagr   r   r   platform_tags   s0    





r   )(
__future__r   collections
contextlib	functoolsrB   rZ   ru   r\   typingr   r   r   r   Z_elffiler   r	   r
   r   r!   r"   r#   contextmanagerr   r%   r&   r5   defaultdictr8   r@   r9   rJ   rV   rW   ra   	lru_cacherb   ro   rz   r   r   r   r   r   <module>   s>   
,
