
    h                     l   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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m Z  dd
l!m"Z"  ejF                  e$      Z%de&de'fdZ( G d d      Z) e jT                  d      dee&   ddfd       Z+ G d de      Z,y)    N)IteratorListOptionalSequenceSetTuple)NormalizedNamecanonicalize_name)BaseDistributionBaseEnvironment)Wheel
deprecated)WHEEL_EXTENSION   )BadMetadataBasePathget_dist_canonical_nameget_info_location)Distributionlocationreturnc                    | j                  t              syt        j                  j	                  |       syt
        j                  j                  t        j                  j                  |             syt        j                  |       S )NF)endswithr   ospathisfiler   wheel_file_rematchbasenamezipfile
is_zipfiler   s    OD:\EasyAligner\venv\Lib\site-packages\pip/_internal/metadata/importlib/_envs.py_looks_like_wheelr%      s]    _-77>>(#$$RWW%5%5h%?@h''    c                       e Zd ZdZeej                  j                  ee	   f   Z
ddZdedee
   fdZdedee   fdZdedee   fdZdedee   fd	Zdedee   fd
Zdedee   fdZy)_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                 "    t               | _        y N)set_found_names)selfs    r$   __init__z_DistributionFinder.__init__1   s    14r&   r   c              #   l  K   t        |      ryt        j                  j                  |g      D ]I  }t	        |      }	 t        |      }|| j                  v r)| j                  j                  |       ||f K y# t        $ r+}t        j                  d||j                         Y d}~|d}~ww xY ww)z!Find distributions in a location.N)r   zSkipping %s due to %s)r%   	importlibmetadatadistributionsr   r   r   loggerwarningreasonr,   add)r-   r   distinfo_locationnamees         r$   
_find_implz_DistributionFinder._find_impl4   s     
 X& &&448*4ED-d3M.t4 t(((!!$'%% F  6qxxPs.   <B4A=
3B4=	B1!B,'B4,B11B4c              #   ~   K   | j                  |      D ]%  \  }}|d}n|j                  }t        |||       ' yw)ziFind distributions in a location.

        The path can be either a directory, or a ZIP archive.
        N)r;   parentr   )r-   r   r7   r8   installed_locations        r$   findz_DistributionFinder.findI   sH     
 $(??8#<D-$9="%2%9%9"t]4FGG $=s   ;=c              #     K   t        j                  |      }|j                         sy|j                         D ]  }|j                  dk7  r|j                         5 }d |D        }t        d |D        d      }ddd       sKt        |j                  |            }| j                  |      D ]  \  }}	t        ||	|         y# 1 sw Y   QxY ww)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              3   <   K   | ]  }|j                           y wr*   )strip.0lines     r$   	<genexpr>z2_DistributionFinder.find_linked.<locals>.<genexpr>e   s     4!$!s   c              3   &   K   | ]	  }|s|  y wr*    rC   s     r$   rF   z2_DistributionFinder.find_linked.<locals>.<genexpr>f   s     "BEDT4Es    )pathlibPathis_diriterdirsuffixopennextstrjoinpathr;   r   )
r-   r   r   childflines
target_reltarget_locationr7   r8   s
             r$   find_linkedz_DistributionFinder.find_linkedU   s      ||H%{{}\\^E||{*4!4!"BE"BBG
  !$--
";<O'+'G#m"4== (H $ s   ACC	9AC	C	Cc              #     K   ddl m} ddlm} t	        j
                  |      5 }|D ]H  }|j                  j                  d      s ||j                        D ]  }|j                  |        J 	 d d d        y # 1 sw Y   y xY ww)Nr   )find_distributionspkg_resourcesz.egg)
pip._vendor.pkg_resourcesrZ   pip._internal.metadatar\   r   scandirr9   r   r   r   )r-   r   rZ   legacyitentryr7   s          r$   _find_eggs_in_dirz%_DistributionFinder._find_eggs_in_dirm   sh     @BZZ!Rzz**62.uzz:D --d33 ;  "!!s   "BAA<3	B<BBc              #      K   ddl m} ddlm} 	 t	        j
                  |      } |||      D ]  }|j                  |        y # t        j                  $ r Y y w xY ww)Nr   )find_eggs_in_zipr[   )r]   re   r^   r\   	zipimportzipimporterZipImportErrorr   )r-   r   re   r`   importerr7   s         r$   _find_eggs_in_zipz%_DistributionFinder._find_eggs_in_zipy   s^     >B	 ,,X6H %Xx8D%%d++ 9 '' 		s'   A A "A AA AA c              #      K   t         j                  j                  |      r| j                  |      E d{    t	        j
                  |      r| j                  |      E d{    yy7 47 w)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   isdirrc   r!   r"   rj   )r-   r   s     r$   	find_eggsz_DistributionFinder.find_eggs   s\      77=="--h777h'--h777 ( 87s!   4A/A+-A/$A-%A/-A/)r   N)__name__
__module____qualname____doc__r   r0   r1   r   r   r   FoundResultr.   rQ   r   r;   r   r?   rX   rc   rj   rm   rH   r&   r$   r(   r(   "   s    
 	**77(9KKLK7&3 &8K+@ &*
HS 
HX.>%? 
H>C >H5E,F >0
4# 
4(;K2L 
4
,# 
,(;K2L 
,8# 8(3C*D 8r&   r(   )maxsizec                 *    t        d|  dddd       y )NzLoading egg at z is deprecated.z#to use pip for package installationz24.3i*0  )r5   replacementgone_inissuer   r#   s    r$   _emit_egg_deprecationrx      s     
/:9	r&   c                       e Zd Zdee   ddfdZedefd       Zede	e
e      defd       Zdee   fdZdede	e   fd	Zy)
Environmentpathsr   Nc                     || _         y r*   )_paths)r-   r{   s     r$   r.   zEnvironment.__init__   s	    r&   c                 .     | t         j                        S r*   sysr   )clss    r$   defaultzEnvironment.default   s    388}r&   c                 B    | | t         j                        S  | |      S r*   r   )r   r{   s     r$   
from_pathszEnvironment.from_paths   s    =sxx= 5zr&   c              #     K   t               }| j                  D ]c  }|j                  |      E d {    |j                  |      D ]  }t	        |j
                         |  |j                  |      E d {    e y 7 O7 	wr*   )r(   r}   r?   rm   rx   r   rX   )r-   finderr   r7   s       r$   _iter_distributionszEnvironment._iter_distributions   ss     $&H{{8,,,((2%dmm4
 3 ))(333 $,
 4s"   .BB AB8B9BBr9   c                 d    t        |      fd| j                         D        }t        |d       S )Nc              3   @   K   | ]  }|j                   k(  r|  y wr*   )canonical_name)rD   distributionr   s     r$   rF   z/Environment.get_distribution.<locals>.<genexpr>   s'      
 =**n<  =s   )r
   iter_all_distributionsrP   )r-   r9   matchesr   s      @r$   get_distributionzEnvironment.get_distribution   s4    *40
 $ ; ; =

 GT""r&   )rn   ro   rp   r   rQ   r.   classmethodr   r   r   r   r   r   r   r   r   rH   r&   r$   rz   rz      s    hsm      xS	2   
4X.>%? 4#S #X6F-G #r&   rz   )-	functoolsimportlib.metadatar0   loggingr   rJ   r   r!   rf   typingr   r   r   r   r   r   pip._vendor.packaging.utilsr	   r
   pip._internal.metadata.baser   r   pip._internal.models.wheelr   pip._internal.utils.deprecationr   pip._internal.utils.filetypesr   _compatr   r   r   r   _distsr   	getLoggerrn   r3   rQ   boolr%   r(   	lru_cacherx   rz   rH   r&   r$   <module>r      s       	  
   A A I I , 6 9 V V  			8	$( ( (o8 o8d T"HSM d  ##/ #r&   