U
    ZÊ¹jr
  ã                	   @   s&  d 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 G dd„ deƒZeee dœd	d
„Zejeee dœdd„ƒZe	e ee dœdd„Zedk�r"ddlZe ¡ Ze d¡sÊtdƒ‚edeƒ edeejƒƒ eddd� ee dde dd¡d ¡ƒ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.
é    N)ÚIteratorÚ
NamedTupleÚOptionalÚSequenceé   )ÚELFFilec                   @   s   e Zd ZU eed< eed< dS )Ú_MuslVersionÚmajorÚminorN)Ú__name__Ú
__module__Ú__qualname__ÚintÚ__annotations__© r   r   úb/var/www/html/bwave/python/venv/lib/python3.8/site-packages/wheel/vendored/packaging/_musllinux.pyr      s   
r   )Ú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>   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$   )Ú
executabler   c              
   C   st   z$t | dƒ�}t|ƒj}W 5 Q R X W n tttfk
r@   Y dS X |dksRd|krVdS tj|g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   T)ÚstderrÚtext)Úopenr   ÚinterpreterÚOSErrorÚ	TypeErrorÚ
ValueErrorÚ
subprocessÚrunÚPIPEr$   r'   )r%   ÚfÚldÚprocr   r   r   Ú_get_musl_version   s    r4   )Úarchsr   c                 c   sR   t tjƒ}|dk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_Ú_)r4   Úsysr%   Úranger
   r	   )r5   Úsys_muslÚarchr
   r   r   r   Úplatform_tags6   s    
r=   Ú__main__zlinux-z	not linuxzplat:zmusl:ztags:ú )Úendz[.-]r8   ú-r6   z
      )Ú__doc__Ú	functoolsr   r.   r9   Útypingr   r   r   r   Ú_elffiler   r   Ústrr$   Ú	lru_cacher4   r=   r   Ú	sysconfigÚget_platformÚplatÚ
startswithÚAssertionErrorÚprintr%   ÚsubÚsplitÚtr   r   r   r   Ú<module>   s(   


"