o
    üÞ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   úT/var/www/html/premium_crap/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 )Né2   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 r…t|	 }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@    



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