a  ze@sdZddlZddlmZddlmZddlmZmZddl m Z m Z ddl m Z ddlmZmZdd lmZdd lmZd ZeeZGd d d eZddZddZddZddZddZddZddZ dS)z0Support functions for working with wheel files. N)Message)Parser)DictTuple) BadZipFileZipFile)canonicalize_name)DistInfoDistribution Distribution)UnsupportedWheel) DictMetadata)rcs,eZdZdZfddZfddZZS) WheelMetadatazaMetadata provider that maps metadata decoding exceptions to our internal exception type. cst|||_dS)N)super__init__ _wheel_name)selfmetadata wheel_name __class__[/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/utils/wheel.pyrs zWheelMetadata.__init__c sNzt|WStyH}z"td|jd|WYd}~n d}~00dS)NzError decoding metadata for : )r get_metadataUnicodeDecodeErrorr r)rnameerrrr s zWheelMetadata.get_metadata)__name__ __module__ __qualname____doc__rr __classcell__rrrrrs rc st||\}fdd|D}i}|D]`}|dd\}}zt||||<Wq,ty}z td|t|WYd}~q,d}~00q,t||} t|| |dS)zaGet a pkg_resources distribution given a wheel. :raises UnsupportedWheel: on any errors cs g|]}|dr|qS)/) startswith.0pinfo_dirrr 3z8pkg_resources_distribution_for_wheel..r#r {} has an invalid wheel, {}N)locationr project_name) parse_wheelnamelistsplitread_wheel_metadata_filer formatstrrr ) wheel_ziprr-_metadata_files metadata_textpath metadata_namerrrr(r$pkg_resources_distribution_for_wheel+s, r;c Cslz t||}t||}t|}Wn8tyX}z td|t|WYd}~n d}~00t||||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. r,N)wheel_dist_info_dirwheel_metadata wheel_versionr r3r4check_compatibility)r5rr)rversionrrrrr/Cs   * r/cCsdd|D}dd|D}|s,tdt|dkrLtdd||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)r1r%rrr ^r+z&wheel_dist_info_dir..cSsg|]}|dr|qS)z .dist-info)endswith)r&srrrr*`r+z'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})r0r lenr3joinrr$)sourcersubdirs info_dirsr) info_dir_namecanonical_namerrrr<Vs$  r<c CsPz ||WStttfyJ}z td|d|WYd}~n d}~00dS)Nzcould not read z file: )readrKeyError RuntimeErrorr )rFr9rrrrr2xs r2c Csf|d}t||}z |}Wn8tyX}z td|d|WYd}~n d}~00t|S)ziReturn the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel. z/WHEELzerror decoding rN)r2decoderr rparsestr)rF dist_info_dirr9wheel_contents wheel_textrrrrr=s   *r=cCs\|d}|durtd|}zttt|dWStyVtd|Yn0dS)zbGiven WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel. z Wheel-VersionNzWHEEL is missing Wheel-Version.zinvalid Wheel-Version: )r striptuplemapintr1 ValueError) wheel_data version_textr@rrrr>s 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 piprSz*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLEr r3rErVr4loggerwarning)r@rrrrr?s r?)!r!logging email.messager email.parserrtypingrrzipfilerrpip._vendor.packaging.utilsrpip._vendor.pkg_resourcesr r pip._internal.exceptionsr !pip._internal.utils.pkg_resourcesr r[ getLoggerrr\rr;r/r<r2r=r>r?rrrrs&      "