o Ec@sLdZddlZddlmZddlmZddlmZmZddl m Z m Z ddl m Z ddlmZmZdd lmZdd lmZd ZeeZGd d d eZde dededefddZde dedeeeffddZde dedefddZde dedefddZde dedefddZ dedee!d ffd!d"Z"d#ee!d fdeddfd$d%Z#dS)&z0Support functions for working with wheel files. N)Message)Parser)DictTuple) BadZipFileZipFile)canonicalize_name)DistInfoDistribution Distribution)UnsupportedWheel) DictMetadata)rcsLeZdZdZdeeefdeddffdd Zdedeffd d ZZ S) WheelMetadatazaMetadata provider that maps metadata decoding exceptions to our internal exception type. metadata wheel_namereturnNcst|||_dS)N)super__init__ _wheel_name)selfrr __class__L/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/utils/wheel.pyrs  zWheelMetadata.__init__namec s>zt|WSty}z td|jd|d}~ww)NzError decoding metadata for : )r get_metadataUnicodeDecodeErrorr r)rrerrrrszWheelMetadata.get_metadata) __name__ __module__ __qualname____doc__rstrbytesrr __classcell__rrrrrs"r wheel_ziprlocationrc st||\}fdd|D}i}|D])}|dd\}}z t||||<Wqty?}z td|t|d}~wwt||} t|| |dS)zaGet a pkg_resources distribution given a wheel. :raises UnsupportedWheel: on any errors cs g|] }|dr|qS)/) startswith.0pinfo_dirrr 2s z8pkg_resources_distribution_for_wheel..r(r {} has an invalid wheel, {}N)r'rZ project_name) parse_wheelnamelistsplitread_wheel_metadata_filer formatr#rr ) r&rr'_Zmetadata_filesZ metadata_textpathZ metadata_namerrrr-r$pkg_resources_distribution_for_wheel)s r8c Cs`zt||}t||}t|}Wnty&}z td|t|d}~wwt||||fS)zExtract information from the provided wheel, ensuring it meets basic standards. Returns the name of the .dist-info directory and the parsed WHEEL metadata. r0N)wheel_dist_info_dirwheel_metadata wheel_versionr r5r#check_compatibility)r&rr.rversionrrrrr1Bs    r1sourcecCsdd|D}dd|D}|stdt|dkr&tdd||d }t|}t|}||s?td |||S) zReturns the name of the contained .dist-info directory. Raises AssertionError or UnsupportedWheel if not found, >1 found, or it doesn't match the provided name. cSsh|] }|dddqS)r(r r)r3r*rrr [sz&wheel_dist_info_dir..cSsg|] }|dr|qS)z .dist-info)endswith)r+srrrr/]sz'wheel_dist_info_dir..z.dist-info directory not foundr z)multiple .dist-info directories found: {}z, rz2.dist-info directory {!r} does not start with {!r})r2r lenr5joinrr))r>rsubdirsZ info_dirsr.Z info_dir_nameZcanonical_namerrrr9Ts$  r9r7c Cs@z||WStttfy}z td|d|d}~ww)Nzcould not read z file: )readrKeyError RuntimeErrorr )r>r7rrrrr4us  r4 dist_info_dirc CsZ|d}t||}z|}Wnty&}z td|d|d}~wwt|S)ziReturn the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel. z/WHEELzerror decoding rN)r4decoderr rZparsestr)r>rHr7Zwheel_contentsZ wheel_textrrrrr:~s    r: wheel_data.cCsT|d}|dur td|}z ttt|dWSty)td|w)zbGiven WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel. z Wheel-VersionNzWHEEL is missing Wheel-Version.zinvalid Wheel-Version: )r striptuplemapintr3 ValueError)rJZ version_textr=rrrr;s r;r=c CsT|dtdkrtd|dtt||tkr(tddtt|dSdS)aRaises errors or warns if called with an incompatible Wheel-Version. pip should refuse to install a Wheel-Version that's a major series ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when installing a version only minor version ahead (e.g 1.2 > 1.1). version: a 2-tuple representing a Wheel-Version (Major, Minor) name: name of wheel or package to raise exception about :raises UnsupportedWheel: when an incompatible Wheel-Version is given rzB{}'s Wheel-Version ({}) is not compatible with this version of piprKz*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLEr r5rCrNr#loggerZwarning)r=rrrrr<s r<)$r"ZloggingZ email.messagerZ email.parserrtypingrrZzipfilerrZpip._vendor.packaging.utilsrZpip._vendor.pkg_resourcesr r Zpip._internal.exceptionsr Z!pip._internal.utils.pkg_resourcesr rQZ getLoggerrrRrr#r8r1r9r$r4r:rOr;r<rrrrs8       ! "