o
    g¹«jÖ
  ã                	   @  s  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r0ddlmZmZ G dd	„ d	e	ƒZd%dd„Zejd&dd„ƒZ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 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   úT/var/www/html/laksyashrimp/venv/lib/python3.10/site-packages/packaging/_musllinux.pyr	      s   
 r	   ÚoutputÚstrÚreturnú_MuslVersion | Nonec                 C  sx   dd„ dd„ |   ¡ D ƒD ƒ}t|ƒdk s|d d d… dkr d S t d	|d
 ¡}|s,d S tt| d
¡ƒt| d¡ƒd�S )Nc                 S  s   g | ]}|r|‘qS r   r   ©Ú.0Únr   r   r   Ú
<listcomp>   s    z'_parse_musl_version.<locals>.<listcomp>c                 s  s   � | ]}|  ¡ V  qd S )N)Ústripr   r   r   r   Ú	<genexpr>   s   € 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'   Ú
executablec              
   C  sˆ   zt | dƒ�}t|ƒj}W d  ƒ n1 sw   Y  W n tttfy)   Y dS w |du s2d|vr4d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   ÚarchsúSequence[str]úIterator[str]c                 c  sT   � t tjƒ}|du rdS | D ]}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   €
ÿÿrC   Ú__main__zlinux-z	not linuxzplat:zmusl:ztags:ú )Úendz[.-]r>   ú-r<   z
      )r   r   r   r   )r(   r   r   r   )r9   r:   r   r;   )Ú__doc__Ú
__future__r   Ú	functoolsr"   r2   r?   Útypingr   r   Ú_elffiler   Úcollections.abcr   r   r	   r'   Ú	lru_cacher8   rC   r   Ú	sysconfigÚget_platformÚplatÚ
startswithÚprintr(   ÚsubÚsplitÚtr   r   r   r   Ú<module>   s4    



$ö	