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Zd dlZd dlm	Z	m
Z
mZmZmZmZ d dlmZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ dd	lmZmZmZ dd
lm Z  de!de"fddZ#G dd dZ$e j%dddee! ddfddZ&G dd deZ'dS )    N)IteratorListOptionalSequenceSetTuple)NormalizedNamecanonicalize_name)BaseDistributionBaseEnvironment)Wheel
deprecated)WHEEL_EXTENSION   )BasePathget_dist_nameget_info_location)Distributionlocationreturnc                 C   s@   |  tsdS tj| sdS tjtj| sdS t	
| S )NF)endswithr   ospathisfiler   wheel_file_rematchbasenamezipfile
is_zipfiler    r!   }C:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\pip/_internal/metadata/importlib/_envs.py_looks_like_wheel   s   

r#   c                   @   s   e Zd ZdZeejjee	 f Z
dddZdedee
 fddZdedee fd	d
Zdedee fddZdedee fddZdedee fddZdedee fddZdS )_DistributionFindera$  Finder to locate distributions.

    The main purpose of this class is to memoize found distributions' names, so
    only one distribution is returned for each package name. At lot of pip code
    assumes this (because it is setuptools's behavior), and not doing the same
    can potentially cause a distribution in lower precedence path to override a
    higher precedence one if the caller is not careful.

    Eventually we probably want to make it possible to see lower precedence
    installations as well. It's useful feature, after all.
    r   Nc                 C   s   t  | _d S N)set_found_names)selfr!   r!   r"   __init__.   s   z_DistributionFinder.__init__r   c                 c   s^    t |rdS tjj|gdD ]}tt|}|| jv rq| j| t|}||fV  qdS )z!Find distributions in a location.N)r   )	r#   	importlibmetadatadistributionsr	   r   r'   addr   )r(   r   distZnormalized_nameinfo_locationr!   r!   r"   
_find_impl1   s   
z_DistributionFinder._find_implc                 c   s<    |  |D ]\}}|du rd}n|j}t|||V  qdS )ziFind distributions in a location.

        The path can be either a directory, or a ZIP archive.
        N)r0   parentr   )r(   r   r.   r/   installed_locationr!   r!   r"   findB   s   z_DistributionFinder.findc           
   	   c   s    t |}| sdS | D ]H}|jdkrq| }dd |D }tdd |D d}W d   n1 s8w   Y  |s@qt||}| 	|D ]\}}	t
||	|V  qLqdS )a  Read location in egg-link files and return distributions in there.

        The path should be a directory; otherwise this returns nothing. This
        follows how setuptools does this for compatibility. The first non-empty
        line in the egg-link is read as a path (resolved against the egg-link's
        containing directory if relative). Distributions found at that linked
        location are returned.
        Nz	.egg-linkc                 s   s    | ]}|  V  qd S r%   )strip.0liner!   r!   r"   	<genexpr>^       z2_DistributionFinder.find_linked.<locals>.<genexpr>c                 s   s    | ]}|r|V  qd S r%   r!   r5   r!   r!   r"   r8   _   r9    )pathlibPathis_diriterdirsuffixopennextstrjoinpathr0   r   )
r(   r   r   childflinesZ
target_relZtarget_locationr.   r/   r!   r!   r"   find_linkedN   s$   
	

z_DistributionFinder.find_linkedc                 c   s~    ddl m} ddlm} t|#}|D ]}|jdsq||jD ]}|	|V  q#qW d    d S 1 s8w   Y  d S )Nr   )find_distributionspkg_resourcesz.egg)
pip._vendor.pkg_resourcesrH   pip._internal.metadatarJ   r   scandirnamer   r   r   )r(   r   rH   legacyitentryr.   r!   r!   r"   _find_eggs_in_dirf   s   "z%_DistributionFinder._find_eggs_in_dirc                 c   s`    ddl m} ddlm} zt|}W n tjy   Y d S w |||D ]}||V  q%d S )Nr   )find_eggs_in_ziprI   )rK   rS   rL   rJ   	zipimportzipimporterZipImportErrorr   )r(   r   rS   rO   importerr.   r!   r!   r"   _find_eggs_in_zipr   s   z%_DistributionFinder._find_eggs_in_zipc                 c   s@    t j|r| |E dH  t|r| |E dH  dS dS )a  Find eggs in a location.

        This actually uses the old *pkg_resources* backend. We likely want to
        deprecate this so we can eventually remove the *pkg_resources*
        dependency entirely. Before that, this should first emit a deprecation
        warning for some versions when using the fallback since importing
        *pkg_resources* is slow for those who don't need it.
        N)r   r   isdirrR   r   r   rX   )r(   r   r!   r!   r"   	find_eggs~   s   	
z_DistributionFinder.find_eggs)r   N)__name__
__module____qualname____doc__r   r*   r+   r   r   r   ZFoundResultr)   rB   r   r0   r
   r3   rG   rR   rX   rZ   r!   r!   r!   r"   r$      s    
r$   )maxsizec                 C   s   t d|  ddd d d S )NzLoading egg at z is deprecated.z$to use pip for package installation.)reasonreplacementgone_inr   r    r!   r!   r"   _emit_egg_deprecation   s
   

rc   c                   @   sz   e Zd Zdee ddfddZedefddZede	e
e  defdd	Zdee fd
dZdede	e fddZdS )Environmentpathsr   Nc                 C   s
   || _ d S r%   )_paths)r(   re   r!   r!   r"   r)      s   
zEnvironment.__init__c                 C   s
   | t jS r%   sysr   )clsr!   r!   r"   default   s   
zEnvironment.defaultc                 C   s   |d u r	| t jS | |S r%   rg   )ri   re   r!   r!   r"   
from_paths   s   
zEnvironment.from_pathsc                 c   sN    t  }| jD ]}||E d H  ||D ]}|V  q||E d H  qd S r%   )r$   rf   r3   rZ   rG   )r(   finderr   r.   r!   r!   r"   _iter_distributions   s   
zEnvironment._iter_distributionsrN   c                    s     fdd|   D }t|d S )Nc                 3   s"    | ]}|j t kr|V  qd S r%   )canonical_namer	   )r6   distributionrN   r!   r"   r8      s    z/Environment.get_distribution.<locals>.<genexpr>)iter_all_distributionsrA   )r(   rN   matchesr!   rp   r"   get_distribution   s   

zEnvironment.get_distribution)r[   r\   r]   r   rB   r)   classmethodr   rj   r   r   rk   r   r
   rm   rs   r!   r!   r!   r"   rd      s    
rd   )(	functoolsimportlib.metadatar*   r   r;   rh   r   rT   typingr   r   r   r   r   r   pip._vendor.packaging.utilsr   r	   Zpip._internal.metadata.baser
   r   pip._internal.models.wheelr   pip._internal.utils.deprecationr   pip._internal.utils.filetypesr   Z_compatr   r   r   Z_distsr   rB   boolr#   r$   	lru_cacherc   rd   r!   r!   r!   r"   <module>   s(     

n