File: //usr/local/lib/python3.10/dist-packages/pip/_internal/utils/__pycache__/wheel.cpython-310.pyc
o
��ht � @ s� d Z ddlZddlmZ ddlmZ ddlmZmZ ddl m
Z
ddlmZ dZ
e�e�Zd ed
edeeef fdd
�Zded
edefdd�Zdededefdd�Zdededefdd�Zdedeedf fdd�Zdeedf d
eddfdd�ZdS )z/Support functions for working with wheel files.� N)�Message)�Parser)�
BadZipFile�ZipFile)�canonicalize_name)�UnsupportedWheel)� r � wheel_zip�name�returnc
C s^ zt | |�}t| |�}t|�}W n ty% } z t|� d|� ���d}~ww t||� ||fS )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 �check_compatibility)r r
�info_dir�metadata�version�e� r �D/usr/local/lib/python3.10/dist-packages/pip/_internal/utils/wheel.py�parse_wheel s
��
r �sourcec C s� dd� | � � D �}dd� |D �}|std��t|�dkr&td�d�|����|d }t|�}t|�}|�|�sAtd
|�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 �qS )�/r r )�split)�.0�pr r r � <setcomp>+ s z&wheel_dist_info_dir.<locals>.<setcomp>c S s g | ] }|� d �r|�qS )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 z.dist-info directory z does not start with )�namelistr �len�format�joinr �
startswith)r r
�subdirs� info_dirsr �
info_dir_name�canonical_namer r r r $ s �
�r �pathc
C s@ z| � |�W S tttfy } z
td|�d|����d }~ww )Nzcould not read z file: )�readr �KeyError�RuntimeErrorr )r r) r r r r �read_wheel_metadata_fileC s ��r- �
dist_info_dirc
C sZ |� d�}t | |�}z|�� }W n ty& } z
td|�d|����d}~ww t� �|�S )ziReturn the WHEEL metadata of an extracted wheel, if possible.
Otherwise, raise UnsupportedWheel.
z/WHEELzerror decoding z: N)r- �decode�UnicodeDecodeErrorr r �parsestr)r r. r) �wheel_contents�
wheel_textr r r r r
L s
��r
�
wheel_data.c C sT | d }|du rt d��|�� }zttt|�d���W S ty) t d|����w )zbGiven WHEEL metadata, return the parsed Wheel-Version.
Otherwise, raise UnsupportedWheel.
z
Wheel-VersionNzWHEEL is missing Wheel-Version�.zinvalid Wheel-Version: )r �strip�tuple�map�intr �
ValueError)r4 �version_textr r r r r _ s �r r c C sT | d t d krtd�|d�tt| �����| t kr(t�dd�tt| ��� dS dS )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 pipr5 z*Installing from a newer Wheel-Version (%s)N)�VERSION_COMPATIBLEr r"