o knh @s dZddlmZddlZddlZddlZddlZddlmZm Z m Z ddl m Z Gddde Z d$d dZejd%ddZd&ddZedkrddlZeZedsWJdedeedeejedddeedd ed!dd"D] Zeed#dqydSdS)'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__rr?/usr/local/lib/python3.10/dist-packages/packaging/_musllinux.pyrs  routputstrreturn_MuslVersion | NonecCsxdddd|DD}t|dks|ddddkr dStd |d }|s,dStt|d t|dd S) NcSsg|]}|r|qSrr.0nrrr sz'_parse_musl_version..css|]}|VqdS)N)striprrrr sz&_parse_musl_version..rmuslzVersion (\d+)\.(\d+)r)r r ) splitlineslenrematchrr group)rlinesmrrr_parse_musl_versions  r& executablec Cszt|d }t|j}Wdn1swYWn tttfy)YdSw|dus2d|vr4dStj|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   r6archs Sequence[str] Iterator[str]ccsTttj}|dur dS|D]}t|jddD]}d|jd|d|VqqdS)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 rA__main__zlinux-z not linuxzplat:zmusl:ztags: )endz[.-]r<-r:z )rrrr)r'rrr)r7r8rr9)__doc__ __future__r functoolsr!r0r=typingrrr_elffilerrr& lru_cacher6rAr sysconfig get_platformplat startswithprintr'subsplittrrrrs0       "