
    
_d	              
          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 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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j.                                edd        e ej0                  ddej3                  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   )ELFFilec                   "    e Zd ZU eed<   eed<   y)_MuslVersionmajorminorN)__name__
__module____qualname__int__annotations__     I/usr/lib/python3/dist-packages/setuptools/_vendor/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universal_newlines)openr   interpreterOSError	TypeError
ValueError
subprocessrunPIPEr&   r*   )r'   fldprocs       r   _get_musl_versionr7      s    *d# 	(q''B	( 
zV2%>>2$z4PDt{{++	( 	(Y
+ s'   A; A/A; /A84A; ;BBarchc              #      K   t        t        j                        }|yt        |j                  dd      D ]  }d|j
                   d| d|    yw)aT  Generate musllinux tags compatible to the current platform.

    :param arch: Should 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__)r7   sysr'   ranger   r
   )r8   sys_muslr   s      r   platform_tagsr@   6   sY      !0Hx~~r2. ;8>>*!E7!D6::;s   AA__main__zlinux-z	not linuxzplat:zmusl:ztags: )endz[.-]r<   -r:   z
      )__doc__	functoolsr!   r1   r=   typingr   r   r   _elffiler   r	   strr&   	lru_cacher7   r@   r   	sysconfigget_platformplat
startswithprintr'   subsplittr   r   r   <module>rS      s/    	  
 1 1 : 
F F(> F ,# ,(<*@ , ,,; ; ;  z!9!!#D??8$1k1$	'4	'$S^^45	's6266'3

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