a if @sdZddlmZddlZddlZddlZddlZddlmZm Z m Z ddl m Z Gddde Z d d d d d Zejd d dddZdddddZedkrddlZeZedsJdedeedeejedddeedded dd!D]Zeed"dqdS)#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 NamedTupleSequence)ELFFilec@seZdZUded<ded<dS) _MuslVersionintmajorminorN)__name__ __module__ __qualname____annotations__rrx/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/packaging/_musllinux.pyrs rstrz_MuslVersion | None)outputreturncCsxdddd|DD}t|dks<|ddddkr@dStd |d }|sXdStt|d t|dd S) NcSsg|] }|r|qSrr.0nrrr z'_parse_musl_version..css|]}|VqdS)N)striprrrr rz&_parse_musl_version..rmuslzVersion (\d+)\.(\d+)r)r r ) splitlineslenrematchrr group)rlinesmrrr_parse_musl_versions r&) executablerc Csz8t|d}t|j}Wdn1s,0YWntttfyRYdS0|dusdd|vrhdStj|gtjdd}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 rbNrT)stderrtext) openr interpreterOSError TypeError ValueError subprocessrunPIPEr&r))r'fldprocrrr_get_musl_version!s  ,r6z Sequence[str]z Iterator[str])archsrccsRttj}|durdS|D]2}t|jddD]}d|jd|d|Vq,qdS)aGenerate 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__)r6sysr'ranger r )r7sys_muslarchr rrr platform_tags8s r?__main__zlinux-z not linuxzplat:zmusl:ztags: )endz[.-]r:-r8z )__doc__ __future__r functoolsr!r0r;typingrrr_elffilerrr& lru_cacher6r?r sysconfig get_platformplat startswithprintr'subsplittrrrrs*      "