관리-도구
편집 파일: _envs.cpython-38.pyc
U &?�f � @ s$ d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl m Z mZmZm Z mZmZ d dlmZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ dd lmZmZmZm Z dd l!m"Z" e�#e$�Z%e&e'd�dd �Z(G dd� d�Z)e j*dd�ee& dd�dd��Z+G dd� de�Z,dS )� 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 C s@ | � t�sdS tj�| �sdS tj�tj�| ��s6dS t � | �S )NF)�endswithr �os�path�isfiler � wheel_file_re�match�basename�zipfile� is_zipfile�r � r# �T/opt/hc_python/lib/python3.8/site-packages/pip/_internal/metadata/importlib/_envs.py�_looks_like_wheel s r% c @ s� e Zd ZdZeejjee f Z dd�dd�Zee e d�dd�Zee e d�d d �Zee e d�dd�Zee e d�d d�Zee e d�dd�Zee e d�dd�ZdS )�_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. N�r c C s t � | _d S �N)�set�_found_names)�selfr# r# r$ �__init__1 s z_DistributionFinder.__init__r c c s� t |�rdS tjj|gd�D ]v}t|�}zt|�}W n: tk rn } zt�d||j � W Y �qW 5 d}~X Y nX || j kr|q| j �|� ||fV qdS )z!Find distributions in a location.N)r zSkipping %s due to %s)r% � importlib�metadata� distributionsr r r �logger�warning�reasonr* �add)r+ r �dist� info_location�name�er# r# r$ � _find_impl4 s z_DistributionFinder._find_implc c s: | � |�D ]*\}}|dkr d}n|j}t|||�V q dS )ziFind distributions in a location. The path can be either a directory, or a ZIP archive. N)r8 �parentr )r+ r r4 r5 �installed_locationr# r# r$ �findI s z_DistributionFinder.findc c s� t �|�}|�� sdS |�� D ]|}|jdkr.q|�� �(}dd� |D �}tdd� |D �d�}W 5 Q R X |sjqt|�|��}| � |�D ]\}} t || |�V q�qdS )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 qd S r( )�strip��.0�liner# r# r$ � <genexpr>e s z2_DistributionFinder.find_linked.<locals>.<genexpr>c s s | ]}|r|V qd S r( r# r= r# r# r$ r@ f s � )�pathlib�Path�is_dir�iterdir�suffix�open�next�str�joinpathr8 r ) r+ r r �child�f�linesZ target_relZtarget_locationr4 r5 r# r# r$ �find_linkedU s z_DistributionFinder.find_linkedc c sf ddl m} ddlm} t�|��:}|D ].}|j�d�s:q(||j�D ]}|� |�V qDq(W 5 Q R X d S )Nr )�find_distributions�� pkg_resourcesz.egg) �pip._vendor.pkg_resourcesrO �pip._internal.metadatarQ r �scandirr6 r r r )r+ r rO �legacy�it�entryr4 r# r# r$ �_find_eggs_in_dirm s z%_DistributionFinder._find_eggs_in_dirc c s` ddl m} ddlm} zt�|�}W n tjk r> Y d S X |||�D ]}|�|�V qJd S )Nr )�find_eggs_in_ziprP )rR rY rS rQ � zipimport�zipimporter�ZipImportErrorr )r+ r rY rU �importerr4 r# r# r$ �_find_eggs_in_zipy s z%_DistributionFinder._find_eggs_in_zipc c s: t j�|�r| �|�E dH t�|�r6| �|�E dH dS )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 �isdirrX r r! r^ )r+ r r# r# r$ � find_eggs� s z_DistributionFinder.find_eggs)�__name__� __module__�__qualname__�__doc__r r- r. r r r ZFoundResultr, rI r r8 r r; rN rX r^ r` r# r# r# r$ r&