
    e                     &   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j        e          Zd
e
dedeeef         fdZde
dedefdZde
dedefdZde
dedefdZdedeedf         fdZdeedf         deddf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           	         	 t          | |          }t          | |          }t          |          }nB# t          $ r5}t          d                    |t          |                              d}~ww xY wt          ||           ||fS )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_dirwheel_metadatawheel_versionr	   formatstrcheck_compatibility)r   r   info_dirmetadataversiones         P/var/www/html/api/venv/lib/python3.11/site-packages/pip/_internal/utils/wheel.pyparse_wheelr      s    S&y$77!)X66)) S S S<CCD#a&&QQRRRS &&&Xs   /2 
A10A,,A1sourcec                    d |                                  D             }d |D             }|st          d          t          |          dk    r5t          d                    d                    |                              |d         }t          |          }t          |          }|                    |          s#t          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.
    c                 F    h | ]}|                     d d          d         S )/r
   r   )split).0ps     r   	<setcomp>z&wheel_dist_info_dir.<locals>.<setcomp>-   s)    ===aqwwsAq!===    c                 <    g | ]}|                     d           |S )z
.dist-info)endswith)r    ss     r   
<listcomp>z'wheel_dist_info_dir.<locals>.<listcomp>/   s)    @@@qqzz,'?'?@@@@r#   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_names          r   r   r   &   s     >=6??+<+<===G@@G@@@I A?@@@
9~~7>>tyy?S?STT
 
 	
 |H%h//M&t,,N##N33 
@GG. 
 
 	
 Or#   pathc                     	 |                      |          S # t          t          t          f$ r}t	          d|d|          d }~ww xY w)Nzcould not read z file: )readr   KeyErrorRuntimeErrorr	   )r   r0   r   s      r   read_wheel_metadata_filer5   G   se    G{{4    ,/ G G GEEEEEFFFGs    AAAdist_info_dirc                     | d}t          | |          }	 |                                }n'# t          $ r}t          d|d|          d}~ww xY wt	                                          |          S )ziReturn the WHEEL metadata of an extracted wheel, if possible.
    Otherwise, raise UnsupportedWheel.
    z/WHEELzerror decoding z: N)r5   decodeUnicodeDecodeErrorr	   r   parsestr)r   r6   r0   wheel_contents
wheel_textr   s         r   r   r   P   s     ###D-fd;;NB#**,,

 B B B@@@1@@AAAB 88Z(((s   , 
AAA
wheel_data.c                    | d         }|t          d          |                                }	 t          t          t          |                    d                              S # t          $ r t          d|          w xY 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)r=   version_textr   s      r   r   r   c   s     o.L?@@@  ""GFSgmmC0011222 F F FDDDEEEFs   4A$ $Br   c                 b   | d         t           d         k    rIt          d                    |d                    t	          t
          |                                         | t           k    rCt                              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 pipr?   z*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLEr	   r   r*   rB   r   loggerwarning)r   r   s     r   r   r   s   s     qz&q)))VD#((3sG+<+<"="=>>
 
 	
 
%	%	%8HHSg&&''	
 	
 	
 	
 	
 
&	%r#   )__doc__loggingemail.messager   email.parserr   typingr   zipfiler   r   pip._vendor.packaging.utilsr   pip._internal.exceptionsr	   rG   	getLogger__name__rH   r   r   r   bytesr5   r   rC   r   r    r#   r   <module>rV      s     ! ! ! ! ! !             ' ' ' ' ' ' ' ' 9 9 9 9 9 9 5 5 5 5 5 5  
	8	$	$7 # %W2E    $ s s    BGW GC GE G G G G)7 )3 )7 ) ) ) )&Fg F%S/ F F F F 
sCx 
 
 
 
 
 
 
 
r#   