o
    5d                      @   s  d dl Zd dlZd dlZd dlZd dlZd dlmZm	Z	m
Z
mZmZmZmZmZ d dlmZ d dlmZmZ d dlmZ d dlmZmZ d dlmZmZmZmZm Z  d dl!m"Z" d d	l#m$Z$ d d
l%m&Z&m'Z' ddl(m)Z)m*Z* G dd dej+j,Z-G dd deZ,dS )    N)
CollectionDictIterableIteratorMappingOptionalSequencecast)Requirement)NormalizedNamecanonicalize_name)parse)InvalidWheelUnsupportedWheel)BaseDistributionBaseEntryPointDistributionVersionInfoPathWheel)normalize_path
safe_extra)parse_wheelread_wheel_metadata_file   )BasePathget_dist_namec                	   @   s   e Zd ZdZdeejef dejddfddZe	de
jd	ed
edd fddZdedeej fddZdedee fddZdS )WheelDistributiona  An ``importlib.metadata.Distribution`` read from a wheel.

    Although ``importlib.metadata.PathDistribution`` accepts ``zipfile.Path``,
    its implementation is too "lazy" for pip's needs (we can't keep the ZipFile
    handle open for the entire lifetime of the distribution object).

    This implementation eagerly reads the entire metadata directory into the
    memory instead, and operates from that.
    filesinfo_locationreturnNc                 C   s   || _ || _d S N)_filesr   )selfr   r    r$   ~C:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\pip/_internal/metadata/importlib/_dists.py__init__/   s   
zWheelDistribution.__init__zfnamelocationc                    sL   t |\ } fdd D }fdd|D }t| }| ||S )Nc                 3   s:    | ]}|   d r|t|d dd fV  qdS )/r   N)
startswithpathlibPurePosixPathsplit).0r(   )info_dirr$   r%   	<genexpr>?   s    
z1WheelDistribution.from_zipfile.<locals>.<genexpr>c                    s   i | ]
\}}|t  |qS r$   )r   )r0   fullpathrelpath)r'   r$   r%   
<dictcomp>D   s    
z2WheelDistribution.from_zipfile.<locals>.<dictcomp>)r   namelistr-   r.   )clsr'   r(   r)   _pathsr   r   r$   )r1   r'   r%   from_zipfile7   s   


zWheelDistribution.from_zipfilepathc                 C   s&   t t|| jv rt| jS t|r!   )r-   r.   strr"   iterFileNotFoundErrorr#   r;   r$   r$   r%   iterdirK   s   
zWheelDistribution.iterdirfilenamec              
   C   s|   z
| j t| }W n
 ty   Y d S w z|d}W |S  ty= } z| jj}d| d| d| d}t|d }~ww )Nzutf-8zError decoding metadata for z: z in z file)	r"   r-   r.   KeyErrordecodeUnicodeDecodeErrorr   parentr   )r#   rA   datatextewheelerrorr$   r$   r%   	read_textQ   s   zWheelDistribution.read_text)__name__
__module____qualname____doc__r   r-   r.   bytesr&   classmethodzipfileZipFiler<   r:   r   r   r@   r   rK   r$   r$   r$   r%   r   $   s*    

r   c                   @   sb  e Zd Zdejjdee dee ddfddZe	de
defd	d
Ze	dede
defddZedee
 fddZedee
 fddZedee
 fddZdee
 fddZedefddZedefddZdedefddZdee
 fddZdede
fd d!Zdee fd"d#Z de!j"j#fd$d%Z$dee
 fd&d'Z%d,d)e&e
 dee' fd*d+Z(dS )-Distributiondistr   installed_locationr    Nc                 C   s   || _ || _|| _d S r!   )_dist_info_location_installed_location)r#   rU   r   rV   r$   r$   r%   r&   `   s   
zDistribution.__init__	directoryc                 C   s&   t |}tjj|}| |||jS r!   )r-   Path	importlibmetadatarT   atrE   )r7   rZ   r   rU   r$   r$   r%   from_directoryj   s   
zDistribution.from_directoryrI   r(   c              
   C   s   z|  }t|||j}W d    n1 sw   Y  W n( tjy2 } zt|j||d }~w tyF } z	t| d| d }~ww | ||jt	
|jS )Nz has an invalid wheel, )
as_zipfiler   r:   r)   rR   
BadZipFiler   r   r   r-   r.   )r7   rI   r(   r'   rU   rH   r$   r$   r%   
from_wheelp   s   
zDistribution.from_wheelc                 C   s   | j d u rd S t| j jS r!   )rX   r<   rE   r#   r$   r$   r%   r)   {   s   
zDistribution.locationc                 C   s   | j d u rd S t| j S r!   )rX   r<   rc   r$   r$   r%   r      s   

zDistribution.info_locationc                 C   s   | j d u rd S tt| j S r!   )rY   r   r<   rc   r$   r$   r%   rV      s   
zDistribution.installed_locationc                 C   s>   | j du rdS tj| j j\}}|dvrdS |ddd S )zrTry to get the name from the metadata directory name.

        This is much faster than reading metadata.
        N)z
.dist-infoz	.egg-info-r   r   )rX   osr;   splitextr(   r/   )r#   stemsuffixr$   r$   r%   _get_dist_name_from_location   s   
z)Distribution._get_dist_name_from_locationc                 C   s   |   pt| j}t|S r!   )ri   r   rW   r   )r#   r(   r$   r$   r%   canonical_name   s   zDistribution.canonical_namec                 C   s   t | jjS r!   )parse_versionrW   versionrc   r$   r$   r%   rl      s   zDistribution.versionr;   c                 C   s   | j t|d uS r!   )rW   rK   r<   r?   r$   r$   r%   is_file   s   zDistribution.is_filec                 c   s6    t | jtjs
d S | jd D ]}|jV  qd S )Nscripts)
isinstancerX   r-   r[   joinpathr@   r(   )r#   childr$   r$   r%   iter_distutils_script_names   s   
z(Distribution.iter_distutils_script_namesc                 C   s$   | j t|}|d u rt||S r!   )rW   rK   r<   r>   )r#   r;   contentr$   r$   r%   rK      s   zDistribution.read_textc                 C   s   | j jS r!   )rW   Zentry_pointsrc   r$   r$   r%   iter_entry_points   s   zDistribution.iter_entry_pointsc                 C   s   t tjj| jjS r!   )r	   emailmessageMessagerW   r]   rc   r$   r$   r%   _metadata_impl   s   zDistribution._metadata_implc                 C   s   dd | j dg D S )Nc                 s   s    | ]}t |V  qd S r!   r   )r0   extrar$   r$   r%   r2      s    
z4Distribution.iter_provided_extras.<locals>.<genexpr>zProvides-Extra)r]   get_allrc   r$   r$   r%   iter_provided_extras   s   z!Distribution.iter_provided_extrasr$   extrasc                 #   sv    dd |D }| j dg D ])}t|  js V  q|s* jddir* V  qt fdd|D r8 V  qd S )Nc                 S   s   g | ]}d t |iqS )ry   r   )r0   rH   r$   r$   r%   
<listcomp>   s    z2Distribution.iter_dependencies.<locals>.<listcomp>zRequires-Distry    c                 3   s    | ]	} j |V  qd S r!   )markerevaluate)r0   contextreqr$   r%   r2      s    z1Distribution.iter_dependencies.<locals>.<genexpr>)r]   rz   r
   r   r   any)r#   r|   Zcontexts
req_stringr$   r   r%   iter_dependencies   s   zDistribution.iter_dependencies)r$   ))rL   rM   rN   r\   r]   rT   r   r   r&   rQ   r<   r   r_   r   rb   propertyr)   r   rV   ri   r   rj   r   rl   r   boolrm   r   rr   rK   r   r   rt   ru   rv   rw   rx   r{   r   r
   r   r$   r$   r$   r%   rT   _   s@    


	 rT   ).email.messageru   importlib.metadatar\   re   r-   rR   typingr   r   r   r   r   r   r   r	   "pip._vendor.packaging.requirementsr
   pip._vendor.packaging.utilsr   r   Zpip._vendor.packaging.versionr   rk   pip._internal.exceptionsr   r   Zpip._internal.metadata.baser   r   r   r   r   pip._internal.utils.miscr   pip._internal.utils.packagingr   pip._internal.utils.wheelr   r   Z_compatr   r   r]   rT   r   r$   r$   r$   r%   <module>   s"    (;