o
    ­—Žj›	  ã                   @  sn   d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm	Z	m
Z
 ddgZddd„Zddd„Zddd„ZdS )é    )ÚannotationsN)Úsite_packagesÚ	user_site)Úrunning_under_virtualenvÚvirtualenv_no_globalÚegg_link_path_from_sys_pathÚegg_link_path_from_locationÚraw_nameÚstrÚreturnú	list[str]c                 C  s   t  dd| ¡d | › d�gS )a€  
    Convert a Name metadata value to a .egg-link name, by applying
    the same substitution as pkg_resources's safe_name function.
    Note: we cannot use canonicalize_name because it has a different logic.

    We also look for the raw name (without normalization) as setuptools 69 changed
    the way it names .egg-link files (https://github.com/pypa/setuptools/issues/4167).
    z[^A-Za-z0-9.]+ú-z	.egg-link)ÚreÚsub)r	   © r   úY/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pip/_internal/utils/egg_link.pyÚ_egg_link_names   s   
þr   ú
str | Nonec                 C  sH   t | ƒ}tjD ]}|D ]}tj ||¡}tj |¡r |    S qqdS )zJ
    Look for a .egg-link file for project name, by walking sys.path.
    N)r   ÚsysÚpathÚosÚjoinÚisfile)r	   Úegg_link_namesÚ	path_itemÚegg_link_nameÚegg_linkr   r   r   r   "   s   
ÿþc                 C  sˆ   g }t ƒ r| t¡ tƒ str| t¡ ntr| t¡ | t¡ t| ƒ}|D ]}|D ]}tj ||¡}tj 	|¡r@|    S q+q'dS )a  
    Return the path for the .egg-link file if it exists, otherwise, None.

    There's 3 scenarios:
    1) not in a virtualenv
       try to find in site.USER_SITE, then site_packages
    2) in a no-global virtualenv
       try to find in site_packages
    3) in a yes-global virtualenv
       try to find in site_packages, then site.USER_SITE
       (don't look in global location)

    For #1 and #3, there could be odd cases, where there's an egg-link in 2
    locations.

    This method will just return the first one found.
    N)
r   Úappendr   r   r   r   r   r   r   r   )r	   Úsitesr   Úsiter   Úegglinkr   r   r   r   /   s$   


€

ÿþ)r	   r
   r   r   )r	   r
   r   r   )Ú
__future__r   r   r   r   Úpip._internal.locationsr   r   Úpip._internal.utils.virtualenvr   r   Ú__all__r   r   r   r   r   r   r   Ú<module>   s    þ

