
    ցj
              
         S r SSKJr  SSKrSSKrSSKrSSKrSSKJrJ	r	  SSK
Jr  \(       a  SSKJrJr   " S S	\	5      rSS
 jr\R"                  SS j5       rSS jr\S:X  a  SSKr\R,                  " 5       r\R1                  S5      (       d   S5       e\" S\5        \" S\" \R4                  5      5        \" SSS9  \" \R6                  " SS\R9                  SS5      S   5      /5       H
  r\" \SS9  M     gg)zPEP 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                  *    \ rS rSr% S\S'   S\S'   Srg)_MuslVersion   intmajorminor N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r       N/mnt/workspace/venv-train/lib/python3.13/site-packages/packaging/_musllinux.pyr   r      s    JJr   r   c                Z   S U R                  5        5        Vs/ s H  o(       d  M  UPM     nn[        U5      S:  d  US   S S S:w  a  g [        R                  " SUS   5      nU(       d  g [	        [        UR                  S5      5      [        UR                  S5      5      S9$ s  snf )	Nc              3  @   #    U  H  oR                  5       v   M     g 7f)N)strip).0ns     r   	<genexpr>&_parse_musl_version.<locals>.<genexpr>   s     @,?q,?s      r      muslzVersion (\d+)\.(\d+)r   )r   r   )
splitlineslenrematchr   r   group)outputr   linesms       r   _parse_musl_versionr+      s    @F,=,=,?@F@1AQ@EF
5zA~q"1/
(%(3Ac!''!*oS_EE Gs
   
B(B(c                :    [        U S5       n[        U5      R                  nSSS5        Wb  SU;  a  g[        R                  " U/S[        R                  SS9n[        UR                  5      $ ! , (       d  f       NS= f! [        [        [
        4 a     gf = f)aD  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/   )
executablefldprocs       r   _get_musl_versionr=   $   s    *d#q''B $ 
zV2%>>2$eJOO$ODt{{++ $#Y
+ s-   B A1B 1
A?;B ?B BBc              #     #    [        [        R                  5      nUc  gU  H8  n[        UR                  SS5       H  nSUR
                   SU SU 3v   M     M:     g7f)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__)r=   sysr9   ranger   r   )archssys_muslarchr   s       r   platform_tagsrG   ;   s]      !0H8>>2r2Ex~~.awav>> 3 s   AA__main__zlinux-z	not linuxzplat:zmusl:ztags: )endz[.-]rA   -r?   z
      )r(   strreturn_MuslVersion | None)r9   rL   rM   rN   )rD   zSequence[str]rM   zIterator[str])__doc__
__future__r   	functoolsr%   r6   rB   typingr   r   _elffiler   collections.abcr   r	   r   r+   	lru_cacher=   rG   r   	sysconfigget_platformplat
startswithprintr9   subsplittr   r   r   <module>r^      s    #  	  
 , 2: 
F , ,,?& z!!#D??8$$1k1$	'4	'$S^^45	'sBFF7CC1CB1GHIJaZ  K r   