
    R"ft
              
          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e      Zded	ee   fd
Z ej                         ded	ee   fd       Zde	e   d	ee   fdZedk(  rddlZ ej(                         Zej-                  d      sJ d        ede        ed eej0                                edd        e ej2                  ddej5                  dd      d               D ]  Z eed        yy)zPEP 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                   "    e Zd ZU eed<   eed<   y)_MuslVersionmajorminorN)__name__
__module____qualname__int__annotations__     6/usr/lib/python3/dist-packages/packaging/_musllinux.pyr
   r
      s    JJr   r
   outputreturnc                 @   d | j                         D        D cg c]  }|s|	 }}t        |      dk  s|d   d d dk7  ry t        j                  d|d         }|sy t	        t        |j                  d            t        |j                  d                  S c c}w )	Nc              3   <   K   | ]  }|j                           y w)N)strip).0ns     r   	<genexpr>z&_parse_musl_version.<locals>.<genexpr>   s     @q@s      r      muslzVersion (\d+)\.(\d+)r   )r   r   )
splitlineslenrematchr
   r   group)r   r   linesms       r   _parse_musl_versionr'      s    @F,=,=,?@F1AQFEF
5zA~q"1/
(%(3Ac!''!*oS_EE Gs
   BB
executablec                 *   	 t        | d      5 }t        |      j                  }ddd       d|vryt        j                  |gt        j                  d      }t        |j                        S # 1 sw Y   LxY w# t        t        t
        f$ r Y yw xY w)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procs       r   _get_musl_versionr8      s    *d# 	(q''B	( 
zV2%>>2$zTBDt{{++	( 	(Y
+ s'   A; A/A; /A84A; ;BBarchsc              #      K   t        t        j                        }|y| D ]5  }t        |j                  dd      D ]  }d|j
                   d| d|   7 yw)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   s       r   platform_tagsrB   6   sh      !0H ?8>>2r2 	?Ex~~.awav>>	??s   AA__main__zlinux-z	not linuxzplat:zmusl:ztags: )endz[.-]r=   -r;   z
      )__doc__	functoolsr"   r2   r>   typingr   r   r   r   _elffiler   r
   strr'   	lru_cacher8   rB   r   	sysconfigget_platformplat
startswithprintr(   subsplittr   r   r   <module>rU      s3    	  
 ; ; : 
F F(> F ,# ,(<*@ , ,,?# ?8C= ?& z!9!!#D??8$1k1$	'4	'$S^^45	's6266'3

30B20FGH !aZ ! r   