
    j
              
         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rddlmZmZ  G d d	e	          Zd"dZej        d#d            Zd$dZedk    rddlZ ej                    Ze                    d          s
J d             ede            ed eej                              edd            e ej        dde                    dd          d                    g          D ]Z eed!           dS dS )%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                  $    e Zd ZU ded<   ded<   dS )_MuslVersionintmajorminorN)__name__
__module____qualname____annotations__     S/var/www/html/python-test/venv/lib/python3.11/site-packages/packaging/_musllinux.pyr   r      s"         JJJJJJJJr   r   outputstrreturn_MuslVersion | Nonec                   d d |                                  D             D             }t          |          dk     s|d         d d         dk    rd S t          j        d|d                   }|sd S t	          t          |                    d                    t          |                    d                    	          S )
Nc                    g | ]}||S r   r   .0ns     r   
<listcomp>z'_parse_musl_version.<locals>.<listcomp>   s    FFF1AFQFFFr   c              3  >   K   | ]}|                                 V  d S )N)stripr   s     r   	<genexpr>z&_parse_musl_version.<locals>.<genexpr>   s*      @@q@@@@@@r      r      muslzVersion (\d+)\.(\d+)r   )r   r   )
splitlineslenrematchr   r   group)r   linesms      r   _parse_musl_versionr-      s    FF@@F,=,=,?,?@@@FFFE
5zzA~~q"1"//t
(%(33A tc!''!**ooS__EEEEr   
executablec                8   	 t          | d          5 }t          |          j        }ddd           n# 1 swxY w Y   n# t          t          t
          f$ r Y dS w xY w|d|vrdS t          j        |gdt          j        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-   r2   )r.   fldprocs       r   _get_musl_versionr?   $   s    *d## 	(q'B	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(Y
+   tt	zV2%%t>2$eJO$OOODt{+++s'   ? 3? 7? 7? AAarchsSequence[str]Iterator[str]c              #     K   t          t          j                  }|dS | D ]-}t          |j        dd          D ]}d|j         d| d| V  .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__)r?   sysr.   ranger   r   )r@   sys_muslarchr   s       r   platform_tagsrK   ;   s       !00H ? ?8>2r22 	? 	?E>x~>>>>>>>>>>	?? ?r   __main__zlinux-z	not linuxzplat:zmusl:ztags: )endz[.-]rF   -rD   z
      )r   r   r   r   )r.   r   r   r   )r@   rA   r   rB   )__doc__
__future__r   	functoolsr(   r9   rG   typingr   r   _elffiler   collections.abcr   r	   r   r-   	lru_cacher?   rK   r   	sysconfigget_platformplat
startswithprintr.   subsplittr   r   r   <module>r_      s
    # " " " " "     				     



 , , , , , , , ,       322222222    :   
F F F F , , , ,,? ? ? ?& z!9!##D??8$$11k111	E'4	E'$$S^44555	E's]FBF7CC1C1CB1GHHIJJ ! !aZ      ! !r   