o
    Ëý°jÅ  ã                   @   s  d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ d	Ze e¡Zd
e
dedeeef fdd„Zde
dedefdd„Zde
dedefdd„Zde
dedefdd„Zdedeedf fdd„Zdeedf deddfdd„ZdS )z0Support functions for working with wheel files.
é    N)ÚMessage)ÚParser)ÚTuple)Ú
BadZipFileÚZipFile)Úcanonicalize_name)ÚUnsupportedWheel)é   r   Ú	wheel_zipÚnameÚreturnc              
   C   s`   zt | |ƒ}t| |ƒ}t|ƒ}W n ty& } z
td |t|ƒ¡ƒ‚d}~ww t||ƒ ||fS )z©Extract 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_dirÚwheel_metadataÚwheel_versionr   ÚformatÚstrÚcheck_compatibility)r
   r   Úinfo_dirÚmetadataÚversionÚe© r   úŒ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/utils/wheel.pyÚparse_wheel   s   

€ÿ
r   Úsourcec                 C   s‚   dd„ |   ¡ D ƒ}dd„ |D ƒ}|stdƒ‚t|ƒdkr&td d |¡¡ƒ‚|d	 }t|ƒ}t|ƒ}| |¡s?td
 ||¡ƒ‚|S )z®Returns 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.
    c                 S   s   h | ]
}|  d d¡d ’qS )ú/r	   r   )Úsplit)Ú.0Úpr   r   r   Ú	<setcomp>-   s    z&wheel_dist_info_dir.<locals>.<setcomp>c                 S   s   g | ]	}|  d ¡r|‘qS )z
.dist-info)Úendswith)r   Úsr   r   r   Ú
<listcomp>/   s    z'wheel_dist_info_dir.<locals>.<listcomp>z.dist-info directory not foundr	   z)multiple .dist-info directories found: {}z, r   z2.dist-info directory {!r} does not start with {!r})Únamelistr   Úlenr   Újoinr   Ú
startswith)r   r   ÚsubdirsÚ	info_dirsr   Úinfo_dir_nameÚcanonical_namer   r   r   r   &   s$   ÿ
ÿÿr   Úpathc              
   C   s@   z|   |¡W S  tttfy } z
td|›d|›�ƒ‚d }~ww )Nzcould not read z file: )Úreadr   ÚKeyErrorÚRuntimeErrorr   )r   r+   r   r   r   r   Úread_wheel_metadata_fileG   s   €ÿr/   Údist_info_dirc              
   C   sZ   |› d�}t | |ƒ}z| ¡ }W n ty& } z
td|›d|›�ƒ‚d}~ww tƒ  |¡S )ziReturn the WHEEL metadata of an extracted wheel, if possible.
    Otherwise, raise UnsupportedWheel.
    z/WHEELzerror decoding z: N)r/   ÚdecodeÚUnicodeDecodeErrorr   r   Úparsestr)r   r0   r+   Úwheel_contentsÚ
wheel_textr   r   r   r   r   P   s   

€ÿr   Ú
wheel_data.c                 C   sT   | d }|du rt dƒ‚| ¡ }zttt| d¡ƒƒW S  ty)   t d|›�ƒ‚w )zbGiven WHEEL metadata, return the parsed Wheel-Version.
    Otherwise, raise UnsupportedWheel.
    zWheel-VersionNzWHEEL is missing Wheel-VersionÚ.zinvalid Wheel-Version: )r   ÚstripÚtupleÚmapÚintr   Ú
ValueError)r6   Úversion_textr   r   r   r   r   c   s   ÿr   r   c              	   C   sT   | d t d krtd |d tt| ƒ¡¡ƒ‚| t kr(t dd tt| ƒ¡¡ dS dS )aå  Raises 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
    r   zB{}'s Wheel-Version ({}) is not compatible with this version of pipr7   z*Installing from a newer Wheel-Version (%s)N)ÚVERSION_COMPATIBLEr   r   r%   r:   r   ÚloggerÚwarning)r   r   r   r   r   r   s   s   þþÿr   )Ú__doc__ÚloggingÚemail.messager   Úemail.parserr   Útypingr   Úzipfiler   r   Úpip._vendor.packaging.utilsr   Úpip._internal.exceptionsr   r>   Ú	getLoggerÚ__name__r?   r   r   r   Úbytesr/   r   r;   r   r   r   r   r   r   Ú<module>   s     
!	"