
    k"g                        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y)z0Support functions for working with wheel files.
    N)Message)Parser)Tuple)
BadZipFileZipFile)canonicalize_name)UnsupportedWheel)   r   	wheel_zipnamereturnc                     	 t        | |      }t        | |      }t        |      }t        ||       ||fS # t        $ r}t        | dt	        |             d}~ww xY w)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	   strcheck_compatibility)r   r   info_dirmetadataversiones         R/var/www/html/djangosite/lib/python3.12/site-packages/pip/_internal/utils/wheel.pyparse_wheelr      sp    I&y$7!)X6) &X  I$'>s1vhGHHIs   #5 	AAAsourcec                    | j                         D ch c]  }|j                  dd      d    }}|D cg c]  }|j                  d      s| }}|st        d      t	        |      dkD  r)t        dj                  dj                  |                  |d   }t        |      }t        |      }|j                  |      st        d|d	|      |S c c}w c c}w )
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.
    /r
   r   z
.dist-infoz.dist-info directory not foundz)multiple .dist-info directories found: {}z, z.dist-info directory z does not start with )	namelistsplitendswithr	   lenformatjoinr   
startswith)	r   r   psubdirss	info_dirsr   info_dir_namecanonical_names	            r   r   r   &   s     ,2??+<=aqwwsAq!=G=#@qqzz,'?@I@?@@
9~7>>tyy?ST
 	
 |H%h/M&t,N##N3#H</D^DVW
 	
 O+ >@s   CCCpathc                     	 | j                  |      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   r*   r   s      r   read_wheel_metadata_filer/   E   sJ    G{{4   ,/ GuEFFGs    =8=dist_info_dirc                     | d}t        | |      }	 |j                         }t	               j                  |      S # t        $ r}t        d|d|      d}~ww xY w)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   s         r   r   r   N   sq     _F#D-fd;NB#**,
 8Z((  B1%@AABs   < 	AAA
wheel_data.c                     | d   }|t        d      |j                         }	 t        t        t        |j                  d                  S # t        $ r t        d|      w xY w)zbGiven WHEEL metadata, return the parsed Wheel-Version.
    Otherwise, raise UnsupportedWheel.
    zWheel-VersionzWHEEL is missing Wheel-Version.zinvalid Wheel-Version: )r	   striptuplemapintr   
ValueError)r7   version_textr   s      r   r   r   a   ss     o.L?@@  "GFSgmmC0122 F!8DEEFs   'A A$r   c                    | d   t         d   kD  r8t        dj                  |dj                  t	        t
        |                         | t         kD  r4t        j                  ddj                  t	        t
        |                    yy)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 pipr9   z*Installing from a newer Wheel-Version (%s)N)VERSION_COMPATIBLEr	   r!   r"   r<   r   loggerwarning)r   r   s     r   r   r   q   sv     qz&q))VD#((3sG+<"=>
 	
 
%	%8HHSg&'	
 
&    )__doc__loggingemail.messager   email.parserr   typingr   zipfiler   r   pip._vendor.packaging.utilsr   pip._internal.exceptionsr	   rA   	getLogger__name__rB   r   r   r   bytesr/   r   r=   r   r    rD   r   <module>rQ      s     !   ' 9 5  
		8	$7 # %W2E $ s s >GW GC GE G)7 )3 )7 )&Fg F%S/ F 
sCx 
 
 
rD   