a oe @s dZddlZddlZddlZddlZddlmZmZmZddl m Z GdddeZ e ee dd d Z ee ee d d d Ze ee dddZedkrddlZeZedsJdedeedeejedddeeddedddD]ZeeddqdS)zPEP 656 support. This module implements logic to detect if the currently running Python is linked against musl, and what musl version is used. N)Iterator NamedTupleOptional)ELFFilec@seZdZUeed<eed<dS) _MuslVersionmajorminorN)__name__ __module__ __qualname__int__annotations__rrHC:\Program Files\Certbot\pkgs\setuptools\_vendor\packaging\_musllinux.pyrs r)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)rr ) 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)stderrZuniversal_newlines) openrZ interpreterOSError TypeError ValueError subprocessrunPIPEr$r')r%fZldprocrrr_get_musl_versions  ,r1)archrccsHttj}|durdSt|jddD]}d|jd|d|Vq$dS)aTGenerate musllinux tags compatible to the current platform. :param arch: Should 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. NZ musllinux__)r1sysr%ranger r)r2Zsys_muslr rrr platform_tags6s r7__main__zlinux-z not linuxzplat:zmusl:ztags: )endz[.-]r4-r3z )__doc__ functoolsrr,r5typingrrrZ_elffilerrstrr$ lru_cacher1r7r Z sysconfigZ get_platformZplat startswithprintr%subsplittrrrrs(     "