a
    <BìjW%  ã                   @  s–  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œ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&ed/d0ƒd1ed/d2ƒd3ed/d4ƒd5iZ'd6ed7< dd8d9œd:d;„Z(dS )<é    )ÚannotationsN)Ú	GeneratorÚIteratorÚ
NamedTupleÚSequenceé   )ÚEIClassÚEIDataÚELFFileÚEMachinel      ~ i   i   >   Úaarch64Zriscv64Úx86_64Úppc64leÚs390xZloongarch64Úppc64Ú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   ú_/mnt/bigstor/www/usecases/.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_i6867   s    

ÿ
þ
ür+   zSequence[str])r   Úarchsr   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   ó    z'_have_compatible_abi.<locals>.<genexpr>)r*   r+   Úany)r   r,   r   r   r   Ú_have_compatible_abiA   s
    r5   c                   C  s   dS )Né2   r   r   r   r   r   Ú<lambda>N   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   Q   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_confstrV   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_ctypesi   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   )rU   r   c                 C  sN   t  d| ¡}|s0t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: é   )Ú
stackleveléÿÿÿÿr;   r<   )ÚreÚmatchÚwarningsÚwarnÚRuntimeWarningr9   r:   Úgroup)rU   Úmr   r   r   Ú_parse_glibc_versionš   s    ý
rb   c                  C  s    t ƒ } | d u rtddƒS t| ƒS )NrZ   )rW   r9   rb   )rU   r   r   r   Ú_get_glibc_version­   s    
rc   )r1   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rŠt|dƒrŠt|jƒS |tdd	ƒkr¬t|d
ƒr¬t|jƒS |tddƒkrÎt|dƒrÎt|j	ƒS dS )NFr   TÚmanylinux_compatibler   rX   é   Úmanylinux1_compatibleé   Úmanylinux2010_compatibleé   Úmanylinux2014_compatible)
rc   Ú
_manylinuxrM   Úhasattrrd   r   r9   rf   rh   rj   )r1   rI   Z	sys_glibcrk   Úresultr   r   r   Ú_is_compatible¶   s.    

ÿ
ÿ
rn   rX   ri   Úmanylinux2014rg   Úmanylinux2010re   Ú
manylinux1zdict[_GLibCVersion, str]Ú_LEGACY_MANYLINUX_MAPz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 ]z}|j|jkr˜|j
}nd}t|j
|dƒD ]N}t|j|ƒ}	t||	ƒrªd	jg |	¢|‘R Ž V  t |	¡ }
rª|
› d
|› �V  qªq€qxd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.
    NrX   é   r   r.   é   r   rZ   zmanylinux_{}_{}_{}rH   )r5   Úsysr   r9   Úsetrc   Úranger;   r8   Úappendr<   rn   Úformatrr   Úget)r,   Ztoo_old_glibc2Zcurrent_glibcZglibc_max_listZglibc_majorZglibc_minorr1   Z	glibc_maxZ	min_minorÚglibc_versionZ
legacy_tagr   r   r   Úplatform_tagsÛ   s*    



r|   ))Ú
__future__r   ÚcollectionsÚ
contextlibÚ	functoolsrB   r[   ru   r]   Útypingr   r   r   r   Z_elffiler   r	   r
   r   r&   r'   r(   r/   Úcontextmanagerr   r*   r+   r5   Údefaultdictr8   r@   r9   rJ   rV   rW   rb   Ú	lru_cacherc   rn   rr   r|   r   r   r   r   Ú<module>   s@   
,


ú
