o g@sdZddlZddlmZddlmZddlmZddlm Z m Z ddl m Z ddl mZd ZeeZd e d ed eeeffd dZde d ed efddZde ded efddZde ded efddZded eedffddZdeedfd ed dfddZdS)z0Support functions for working with wheel files. N)Message)Parser)Tuple) BadZipFileZipFile)canonicalize_name)UnsupportedWheel)r wheel_zipnamereturnc 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. z{} has an invalid wheel, {}N)wheel_dist_info_dirwheel_metadata wheel_versionrformatstrcheck_compatibility)r r info_dirmetadataversioner;/usr/lib/python3/dist-packages/pip/_internal/utils/wheel.py parse_wheels    rsourcecCsdd|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)split).0prrr -sz&wheel_dist_info_dir..cSsg|] }|dr|qS)z .dist-info)endswith)rsrrr /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})namelistrlenrjoinr startswith)rr subdirs info_dirsr info_dir_namecanonical_namerrrr &s$  r pathc Cs@z||WStttfy}z td|d|d}~ww)Nzcould not read z file: )readrKeyError RuntimeErrorr)rr+rrrrread_wheel_metadata_fileGs  r/ 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 z: N)r/decodeUnicodeDecodeErrorrrparsestr)rr0r+wheel_contents wheel_textrrrrrPs    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: )rstriptuplemapintr ValueError)r6 version_textrrrrrcs rrc 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 pipr7z*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLErrr%r:rloggerwarning)rr rrrrss r)__doc__logging email.messager email.parserrtypingrzipfilerrpip._vendor.packaging.utilsrpip._internal.exceptionsrr> getLogger__name__r?rrr bytesr/rr;rrrrrrs       ! "