U ʗRe @ st d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl m Z mZmZm Z mZ e e eeedf dddZe e e e dd d ZG dd deZee e d ddZe ee e dddZeee dddZedkrpddlZe Zedstdede edeej eddd ee!dde"d d!d" D ]Z#ee#d#d q\dS )$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)IOIterator NamedTupleOptionalTuple.)ffmtreturnc C s t || t |S N)structunpackreadcalcsize)r r r /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/packaging/_musllinux.py_read_unpacked s r )r r c C sp | d zt| d}W n tjk r0 Y dS X |dd tdkrJdS | tdd zdd d |d \}}}W n tk r Y dS X tj| }zt| |\}}}}}}} W n tjk r Y dS X t | d D ]} | ||| z|t| |\}}} W n tjk r& Y dS X |dkr4q| | t | | d}d |krd dS | S dS )zDetect musl libc location by parsing the Python executable. Based on: https://gist.github.com/lyssdod/f51579ae8d93c8657a5564aefc2ffbca ELF header: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html r 16BN s ELFHHI )IIIIHHHIIIIIIII)r r r )QQQIHHHIIQQQQQQ)r )r r musl)seekr r errortupler KeyErroroperator itemgetterrangeosfsdecoder strip)r idente_fmtp_fmtp_idxp_get_e_phoffe_phentsizee_phnumip_typep_offsetp_fileszinterpreterr r r _parse_ld_musl_from_elf sF r7 c @ s e Zd ZU eed<