o
    'j6h
                  	   @  s  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	m
Z
 ddlmZ G dd de	Zd$ddZejd%ddZd&ddZedkrddlZe ZedsWJ 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 qyd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)Iterator
NamedTupleSequence   )ELFFilec                   @  s   e Zd ZU ded< ded< dS )_MuslVersionintmajorminorN)__name__
__module____qualname____annotations__ r   r   c/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/packaging/_musllinux.pyr      s   
 r   outputstrreturn_MuslVersion | Nonec                 C  sx   dd dd |   D D }t|dk s|d d d dkr d S td	|d
 }|s,d 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&   
executablec              
   C  s   zt | d}t|j}W d   n1 sw   Y  W n tttfy)   Y dS w |du s2d|vr4d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   
r6   archsSequence[str]Iterator[str]c                 c  sT    t tj}|du rdS | D ]}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__)r6   sysr'   ranger   r
   )r7   sys_muslarchr   r   r   r   platform_tags8   s   
rA   __main__zlinux-z	not linuxzplat:zmusl:ztags: )endz[.-]r<   -r:   z
      )r   r   r   r   )r'   r   r   r   )r7   r8   r   r9   )__doc__
__future__r   	functoolsr!   r0   r=   typingr   r   r   _elffiler   r   r&   	lru_cacher6   rA   r   	sysconfigget_platformplat
startswithprintr'   subsplittr   r   r   r   <module>   s0    



"	