U 巀g@sdZddlZddlmZddlmZddlmZddlm Z m Z ddl m Z ddl mZd ZeeZe eeeefd d d Ze eed ddZe eedddZe eedddZeeedfdddZeedfeddddZdS)z0Support functions for working with wheel files. N)Message)Parser)Tuple) BadZipFileZipFile)canonicalize_name)UnsupportedWheel)r) wheel_zipnamereturnc Cshz t||}t||}t|}Wn4tk rT}zt|d|W5d}~XYnXt||||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_versionrcheck_compatibility)r r info_dirmetadataversionerG/opt/hc_python/lib/python3.8/site-packages/pip/_internal/utils/wheel.py parse_wheels   $ r)sourcer r cCsdd|D}dd|D}|s,tdt|dkrLtdd||d }t|}t|}||std |d ||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 /s z'wheel_dist_info_dir..z.dist-info directory not foundr z)multiple .dist-info directories found: {}z, rz.dist-info directory z does not start with )namelistrlenformatjoinr startswith)rr subdirs info_dirsr info_dir_namecanonical_namerrrr &s   r )rpathr c CsNz ||WStttfk rH}ztd|d|W5d}~XYnXdS)Nzcould not read z file: )readrKeyError RuntimeErrorr)rr*rrrrread_wheel_metadata_fileEs r.)r dist_info_dirr c Csd|d}t||}z |}Wn6tk rV}ztd|d|W5d}~XYnXt|S)ziReturn the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel. z/WHEELzerror decoding z: N)r.decodeUnicodeDecodeErrorrrparsestr)rr/r*wheel_contents wheel_textrrrrrNs   &r.) wheel_datar cCs^|d}|dkrtd|}zttt|dWStk rXtd|YnXdS)zbGiven WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel. z Wheel-VersionNzWHEEL is missing Wheel-Version.zinvalid Wheel-Version: )rstriptuplemapintr ValueError)r5 version_textrrrrrasr)rr r c CsR|dtdkr.td|dtt|n |tkrNtddtt|dS)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 pipr6z*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLErr#r$r9strloggerwarning)rr rrrrqs r)__doc__logging email.messager email.parserrtypingrzipfilerrZpip._vendor.packaging.utilsrpip._internal.exceptionsrr= getLogger__name__r?r>rr bytesr.rr:rrrrrrs