a
    ç´«jÖ
  ã                	   @  s0  d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
mZ er`ddlmZmZ G dd	„ d	e	ƒZd
ddœdd„Zejd
ddœdd„ƒZdddœdd„Zedk�r,ddlZe ¡ Ze d¡sÒJ dƒ‚edeƒ edeejƒƒ eddd� ee dd e d!d¡d" ¡gƒD ]Zeed#d� �qdS )$z�PEP 656 support.

This module implements logic to detect if the currently running Python is
linked against musl, and what musl version is used.
é    )ÚannotationsN)ÚTYPE_CHECKINGÚ
NamedTupleé   )ÚELFFile)ÚIteratorÚSequencec                   @  s   e Zd ZU ded< ded< dS )Ú_MuslVersionÚintÚmajorÚminorN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© r   r   úS/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/packaging/_musllinux.pyr	      s   
r	   Ústrz_MuslVersion | None)ÚoutputÚreturnc                 C  sx   dd„ dd„ |   ¡ D ƒD ƒ}t|ƒdk s<|d d d… dkr@d S t d	|d
 ¡}|sXd S tt| d
¡ƒt| d¡ƒd�S )Nc                 S  s   g | ]}|r|‘qS r   r   ©Ú.0Únr   r   r   Ú
<listcomp>   ó    z'_parse_musl_version.<locals>.<listcomp>c                 s  s   | ]}|  ¡ V  qd S )N)Ústripr   r   r   r   Ú	<genexpr>   r   z&_parse_musl_version.<locals>.<genexpr>é   r   é   ÚmuslzVersion (\d+)\.(\d+)r   )r   r   )Ú
splitlinesÚlenÚreÚmatchr	   r
   Úgroup)r   ÚlinesÚmr   r   r   Ú_parse_musl_version   s     r'   )Ú
executabler   c              
   C  sˆ   z8t | dƒ�}t|ƒj}W d  ƒ n1 s,0    Y  W n tttfyR   Y dS 0 |du sdd|vrhdS tj|gdtjdd�}t	|j
ƒS )a`  Detect currently-running musl runtime version.

    This is done by checking the specified executable's dynamic linking
    information, and invoking the loader to parse its output for a version
    string. If the loader is musl, the output would be something like::

        musl libc (x86_64)
        Version 1.2.2
        Dynamic Program Loader
    ÚrbNr   FT)ÚcheckÚstderrÚtext)Úopenr   ÚinterpreterÚOSErrorÚ	TypeErrorÚ
ValueErrorÚ
subprocessÚrunÚPIPEr'   r+   )r(   ÚfÚldÚprocr   r   r   Ú_get_musl_version$   s    ,r8   zSequence[str]zIterator[str])Úarchsr   c                 c  sR   t tjƒ}|du rdS | D ]2}t|jddƒD ]}d|j› d|› d|› �V  q,qdS )aÆ  Generate musllinux 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 musllinux-compatible.

    :returns: An iterator of compatible musllinux tags.
    NéÿÿÿÿÚ
musllinux_Ú_)r8   Úsysr(   Úranger   r   )r9   Úsys_muslÚarchr   r   r   r   Úplatform_tags;   s    
rA   Ú__main__zlinux-z	not linuxzplat:zmusl:ztags:ú )Úendz[.-]r<   ú-r:   z
      )Ú__doc__Ú
__future__r   Ú	functoolsr"   r2   r=   Útypingr   r   Z_elffiler   Úcollections.abcr   r   r	   r'   Ú	lru_cacher8   rA   r   Ú	sysconfigÚget_platformÚplatÚ
startswithÚprintr(   ÚsubÚsplitÚtr   r   r   r   Ú<module>   s.   


$