Re@sdZddlmZddlZddlmZddlmZddlm Z ddl m Z ddl m Z mZdd lmZdd lmZdd lmZerdd lmZdd lmZmZddl mZe rddlmZnddlmZd"ZejeZ GdddeZ!ddZ"ddZ#ddZ$ddZ%ddZ&ddZ'd d!Z(dS)#z0Support functions for working with wheel files. )absolute_importN)Parser)ZipFile)canonicalize_name)DistInfoDistribution)PY2 ensure_str)UnsupportedWheel) DictMetadata)MYPY_CHECK_RUNNING)Message)DictTuple) Distribution) BadZipfile) BadZipFilecs:eZdZdZfddZfddZS) WheelMetadatazaMetadata provider that maps metadata decoding exceptions to our internal exception type. cs#tt|j|||_dS)N)superr__init__ _wheel_name)selfmetadata wheel_name) __class__/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/wheel.pyr(szWheelMetadata.__init__csaytt|j|SWn@tk r\}z tdj|j|WYdd}~XnXdS)Nz"Error decoding metadata for {}: {})rr get_metadataUnicodeDecodeErrorr formatr)rnamee)rrrr-s zWheelMetadata.get_metadata)__name__ __module__ __qualname____doc__rrrr)rrr$s rc st||\}fdd|jD}i}x|D]}t|}|jdd\}}yt||||Cs z8pkg_resources_distribution_for_wheel../rz{} has an invalid wheel, {}Nlocationr project_name) parse_wheelnamelistrsplitread_wheel_metadata_filer rstrrr) wheel_zipr r,_metadata_files metadata_textpath full_path metadata_namer!rr)r)r$pkg_resources_distribution_for_wheel:s  2r:cCsy.t||}t||}t|}WnCtk rs}z#tdj|t|WYdd}~XnXt||||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_versionr rr2check_compatibility)r3r r)rversionr!rrrr._s. r.cCstdd|jD}dd|D}|sDtdt|dkrttdjdj||d }t|}t|}|j|std j||t|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. css%|]}|jdddVqdS)r+rrN)r0)r'r(rrr |sz&wheel_dist_info_dir..cSs%g|]}|jdr|qS)z .dist-info)endswith)r'srrrr*~s z'wheel_dist_info_dir..z.dist-info directory not foundrz)multiple .dist-info directories found: {}z, rz2.dist-info directory {!r} does not start with {!r}) setr/r lenrjoinrr&r)sourcer subdirs info_dirsr) info_dir_namecanonical_namerrrr;ts     r;cCs^y|j|SWnFtttfk rY}ztdj||WYdd}~XnXdS)Nzcould not read {!r} file: {!r})readrKeyError RuntimeErrorr r)rFr7r!rrrr1s r1cCs~dj|}t||}yt|}Wn=tk rm}ztdj||WYdd}~XnXtj|S)ziReturn the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel. z{}/WHEELzerror decoding {!r}: {!r}N)rr1rrr rparsestr)rF dist_info_dirr7wheel_contents wheel_textr!rrrr<s+r<c Cs||d}|dkr"td|j}y ttt|jdSWn'tk rwtdj|YnXdS)zbGiven WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel. z Wheel-VersionNzWHEEL is missing Wheel-Version.zinvalid Wheel-Version: {!r})r striptuplemapintr0 ValueErrorr) wheel_data version_textr?rrrr=s      r=cCss|dtdkrAtdj|djtt|n.|tkrotjddjtt|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 piprRz*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLEr rrErUr2loggerwarning)r?r rrrr>s $ r>)rr))r% __future__rlogging email.parserrzipfilerZpip._vendor.packaging.utilsrZpip._vendor.pkg_resourcesrZpip._vendor.sixrrpip._internal.exceptionsr !pip._internal.utils.pkg_resourcesr pip._internal.utils.typingr email.messager typingr rrrrrZ getLoggerr"r[rr:r.r;r1r<r=r>rrrrs6  %  &