a
ˆlj› ã @ sˆ d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm Z m
Z
ddgZeedœdd „Z
eee dœd
d„Zeee dœdd„ZdS )é N)ÚOptional)Ú
site_packagesÚ user_site)Úrunning_under_virtualenvÚvirtualenv_no_globalÚegg_link_path_from_sys_pathÚegg_link_path_from_location)Úraw_nameÚreturnc C s t dd| ¡d S )zÕ
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.
z[^A-Za-z0-9.]+ú-z .egg-link)ÚreÚsub)r © r ú@/usr/lib/python3.9/site-packages/pip/_internal/utils/egg_link.pyÚ_egg_link_name s r c C s: t | ƒ}tjD ]&}tj ||¡}tj |¡r| S qdS )zJ
Look for a .egg-link file for project name, by walking sys.path.
N)r ÚsysÚpathÚosÚjoinÚisfile)r Ú
egg_link_nameÚ path_itemZegg_linkr r r r s
c C sz g }t ƒ r*| t¡ tƒ sBtrB| t¡ ntr8| t¡ | t¡ t| ƒ}|D ]&}tj ||¡}tj |¡rN| S qNdS )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 Zsitesr ZsiteZegglinkr r r r * s
)r r r Útypingr Zpip._internal.locationsr r Zpip._internal.utils.virtualenvr r Ú__all__Ústrr r r r r r r Ú