o
    g}”el8  ã                   @   sð  U 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 d dlmZ d dlmZ ddlmZmZ dd	lmZmZmZmZmZmZ g d
¢Z e !e"¡Z#ej$ %d¡rnej&Z'nej(Z'e)eddƒZ*e+e,d< ej-dkZ.de/fdd„Z0dee+e+f de/fdd„Z1e j2dd�de/fdd„ƒZ3e j2dd�de/fdd„ƒZ4e j2dd�de/fdd„ƒZ5e j2dd�de/fdd„ƒZ6dee+ de	e+ fd d!„Z7e j2dd�d"ej8d#ej8d$e+ddfd%d&„ƒZ9d"ej8d#ej8d$e+de/fd'd(„Z:e j2dd�d)dddd*œd+e/d,ee+ d-ee+ d.ee+ ddf
d/d0„ƒZ;	)			)	dFd1e+d+e/d,ee+ d-ee+ d2e/d.ee+ defd3d4„Z<de+fd5d6„Z=de+fd7d8„Z>d9e+de/fd:d;„Z?de+fd<d=„Z@de+fd>d?„ZAd@e+dAe+de
e+ fdBdC„ZBd.e+de
e+ fdDdE„ZCdS )Gé    N)ÚAnyÚDictÚIteratorÚListÚOptionalÚTuple)ÚSCHEME_KEYSÚScheme)ÚWINDOWS)Ú
deprecated)Úrunning_under_virtualenvé   )Ú
_distutilsÚ
_sysconfig)ÚUSER_CACHE_DIRÚget_major_minor_versionÚget_src_prefixÚis_osx_frameworkÚsite_packagesÚ	user_site)r   Úget_bin_prefixÚget_bin_userr   Úget_platlibÚget_prefixed_libsÚget_purelibÚ
get_schemer   r   r   Z"_PIP_LOCATIONS_NO_WARN_ON_MISMATCHÚ
platlibdirÚlibÚ_PLATLIBDIR)é   é
   Úreturnc                  C   s8   ddl m}  z| d d }W |dkS  ty   Y dS w )zsThe resolution to bpo-44860 will change this incorrect platlib.

    See <https://bugs.python.org/issue44860>.
    r   ©ÚINSTALL_SCHEMESZ	unix_userÚplatlibFz	$usersite)Údistutils.command.installr#   ÚKeyError)r#   Zunix_user_platlib© r'   úi/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/site-packages/pip/_internal/locations/__init__.pyÚ_looks_like_bpo_448603   s   þÿr)   Úschemec                 C   s\   | d }d|v rt tdƒr| ddtj› d�¡}d|vrdS | dd¡}| dd	¡| d
 kS )Nr$   z/$platlibdir/r   ú/z/lib64/Fz/lib/z
$platbase/z$base/Úpurelib)ÚhasattrÚsysÚreplacer   )r*   r$   Z	unpatchedr'   r'   r(   Ú+_looks_like_red_hat_patched_platlib_purelibA   s   r0   )Úmaxsizec                      s"   ddl m‰  t‡ fdd„dD ƒƒS )z‘Red Hat patches platlib in unix_prefix and unix_home, but not purelib.

    This is the only way I can see to tell a Red Hat-patched Python.
    r   r"   c                 3   s$   � | ]}|ˆ v ot ˆ | ƒV  qd S ©N)r0   ©Ú.0Úkr"   r'   r(   Ú	<genexpr>S   s   € þ

þz*_looks_like_red_hat_lib.<locals>.<genexpr>)Zunix_prefixZ	unix_home)r%   r#   Úallr'   r'   r"   r(   Ú_looks_like_red_hat_libK   s   ýr8   c                  C   s   ddl m}  d| v od| v S )z#Debian adds two additional schemes.r   r"   Z
deb_systemZ
unix_local)r%   r#   r"   r'   r'   r(   Ú_looks_like_debian_schemeZ   s   r9   c                  C   s^   ddl m}  ddlm} | |ƒ ƒ}| ¡  |jtj t	j¡› d�ko.|j
tj t	j
¡› d�kS )a\  Red Hat patches ``sys.prefix`` and ``sys.exec_prefix``.

    Red Hat's ``00251-change-user-install-location.patch`` changes the install
    command's ``prefix`` and ``exec_prefix`` to append ``"/local"``. This is
    (fortunately?) done quite unconditionally, so we create a default command
    object without any configuration to detect this.
    r   )Úinstall)ÚDistributionz/local)r%   r:   Zdistutils.distr;   Zfinalize_optionsÚexec_prefixÚosÚpathÚnormpathr.   Úprefix)r:   r;   Úcmdr'   r'   r(   Ú_looks_like_red_hat_schemeb   s   	
þrB   c                      s.   t jddd�‰ tdd„ ‡ fdd„dD ƒD ƒƒS )a‰  MSYS2 patches distutils and sysconfig to use a UNIX-like scheme.

    However, MSYS2 incorrectly patches sysconfig ``nt`` scheme. The fix is
    likely going to be included in their 3.10 release, so we ignore the warning.
    See msys2/MINGW-packages#9319.

    MSYS2 MINGW's patch uses lowercase ``"lib"`` instead of the usual uppercase,
    and is missing the final ``"site-packages"``.
    ÚntF)Úexpandc                 s   s,   � | ]}d |vod|v o|  d¡ V  qdS )ZLibr   zsite-packagesN)Úendswith)r4   Úpr'   r'   r(   r6   ‚   s
   € ÿ
ÿz1_looks_like_msys2_mingw_scheme.<locals>.<genexpr>c                 3   s   � | ]}ˆ | V  qd S r2   r'   )r4   Úkey©Úpathsr'   r(   r6   „   s   € ©r$   r,   )Ú	sysconfigÚ	get_pathsr7   r'   r'   rH   r(   Ú_looks_like_msys2_mingw_schemev   s   þrM   Úpartsc                 c   sj   � t  d¡}ttdd ƒ}|r|r| |¡s| E d H  d S | D ]}| |¡r/|d dt|ƒ … }|V  qd S )NÚ	LDVERSIONÚabiflagsr   )rK   Úget_config_varÚgetattrr.   rE   Úlen)rN   Z	ldversionrP   Úpartr'   r'   r(   Ú_fix_abiflagsˆ   s   €


ýrU   ÚoldÚnewrG   c                C   s    d}d}t  t|||| |¡ d S )Nz(https://github.com/pypa/pip/issues/10151zSValue for %s does not match. Please report this to <%s>
distutils: %s
sysconfig: %s)ÚloggerÚlogÚ_MISMATCH_LEVEL)rV   rW   rG   Z	issue_urlÚmessager'   r'   r(   Ú_warn_mismatched˜   s   ÿr\   c                C   s   | |krdS t | ||d� dS )NF©rG   T)r\   )rV   rW   rG   r'   r'   r(   Ú_warn_if_mismatch£   s   r^   F©ÚuserÚhomeÚrootr@   r`   ra   rb   r@   c                 C   s&   g d¢}t  td |¡| |||¡ d S )N)zAdditional context:z	user = %rz	home = %rz	root = %rzprefix = %rÚ
)rX   rY   rZ   Újoin)r`   ra   rb   r@   rN   r'   r'   r(   Ú_log_contextª   s   re   Ú	dist_nameÚisolatedc              	      s˜  t j| |||||d�}tr|S tj| |||||d�‰g }tD ]ì}t tˆ|ƒ¡}	t t||ƒ¡}
|	|
kr5qtj	j
dkoT|d uoT|dv oT|	j|
jkoT|	j
 d¡oT|
j
 d¡}|rXq|ontƒ on|dkon|	jj|
jkon|	jj
 d¡}|rrq|dkrztƒ rzq|oŽ|dkoŽt oŽtjdkoŽtdkoŽtƒ }|r’q|pš|pš|pštƒ  oÆ|	jd	d
… dkoÆt|
jƒd	koÆ|
jd	 dkoÆt|
jƒd
k pÀ|
jd dkoÆtƒ pÆtƒ }|rÊqtjdk oßt oß|dv oßtt|	jƒƒ|
jk}|rãqtoë|dv oëtƒ }|rïqtjdd�oût oû|dv }|rÿq| |	|
d|› �f¡ q|�sˆS tj| |||||dd�‰ t‡ ‡fdd„tD ƒƒ�r2t dd d d� ˆS |D ]\}	}
}t!|	|
|d� �q4t"||||d� ˆS )N)r`   ra   rb   rg   r@   ÚpypyrJ   ÚpythonÚheadersr$   )r   é	   r   r   r   )ÚusrÚlocalrl   é   rm   )r   é   )rj   r$   r,   T)Ú
check_home)rj   ÚincludeÚplatincludezscheme.)Zignore_config_filesc                 3   s"   � | ]}ˆ | t ˆ|ƒkV  qd S r2   )rR   r3   ©Zdefault_oldrV   r'   r(   r6   O  s   €  zget_scheme.<locals>.<genexpr>zöConfiguring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621)ÚreasonÚreplacementÚgone_inr]   r_   )#r   r   Ú_USE_SYSCONFIGr   r   ÚpathlibÚPathrR   r.   ÚimplementationÚnameÚparentÚ
startswithr   r8   r
   Úversion_infor   r)   r   rN   rS   rB   r9   ÚtuplerU   rM   rK   Úis_python_buildÚappendZdistutils_schemeÚanyr   r\   re   )rf   r`   ra   rb   rg   r@   rW   Zwarning_contextsr5   Zold_vZnew_vZskip_pypy_special_caseZ$skip_osx_framework_user_special_caseZskip_bpo_44860Zskip_linux_system_special_caseZskip_sysconfig_abiflag_bugZskip_msys2_mingw_bugZskip_cpython_buildrG   r'   rs   r(   r   ½   sî   úú	ÿþ
ý
ü
úÿþýûÿþýüúÿþýü
ú
ÿþüÿÿýù	ø
r   c                  C   s<   t  ¡ } tr| S t ¡ }tt |¡t | ¡dd�rtƒ  |S )NZ
bin_prefixr]   )r   r   rw   r   r^   rx   ry   re   ©rW   rV   r'   r'   r(   r   d  s   r   c                   C   s   t jddd�jS )NÚ T)r`   )r   r   Úscriptsr'   r'   r'   r(   r   o  s   r   Úvaluec                 C   s   t ƒ sdS | dkrdS dS )aõ  Check if the value is Debian's APT-controlled dist-packages.

    Debian's ``distutils.sysconfig.get_python_lib()`` implementation returns the
    default package path controlled by APT, but does not patch ``sysconfig`` to
    do the same. This is similar to the bug worked around in ``get_scheme()``,
    but here the default is ``deb_system`` instead of ``unix_local``. Ultimately
    we can't do anything about this Debian bug, and this detection allows us to
    skip the warning when needed.
    Fz/usr/lib/python3/dist-packagesT)r9   )r†   r'   r'   r(   Ú$_looks_like_deb_system_dist_packagess  s
   
r‡   c                  C   óH   t  ¡ } tr| S t ¡ }t|ƒr|S tt |¡t | ¡dd�r"tƒ  |S )z,Return the default pure-Python lib location.r,   r]   )	r   r   rw   r   r‡   r^   rx   ry   re   rƒ   r'   r'   r(   r   „  ó   r   c                  C   rˆ   )z0Return the default platform-shared lib location.r$   r]   )	r   r   rw   r   r‡   r^   rx   ry   re   rƒ   r'   r'   r(   r   ’  r‰   r   Úv1Úv2c                 C   s   | |kr| gS | |gS )zDeduplicate values from a list.r'   )rŠ   r‹   r'   r'   r(   Ú_deduplicated   s   rŒ   c                 C   sz   t  | ¡\}}trt||ƒS t | ¡\}}tt |¡t |¡dd�tt |¡t |¡dd�g}t|ƒr8t	| d� t||ƒS )z*Return the lib locations under ``prefix``.zprefixed-purelibr]   zprefixed-platlib)r@   )
r   r   rw   rŒ   r   r^   rx   ry   r‚   re   )r@   Znew_pureZnew_platZold_pureZold_platZwarnedr'   r'   r(   r   §  s$   
ýýú

r   )FNNFN)DÚ	functoolsÚloggingr=   rx   r.   rK   Útypingr   r   r   r   r   r   Zpip._internal.models.schemer   r	   Úpip._internal.utils.compatr
   Úpip._internal.utils.deprecationr   Úpip._internal.utils.virtualenvr   r„   r   r   Úbaser   r   r   r   r   r   Ú__all__Ú	getLoggerÚ__name__rX   ÚenvironÚgetÚDEBUGrZ   ÚWARNINGrR   r   ÚstrÚ__annotations__r~   rw   Úboolr)   r0   Ú	lru_cacher8   r9   rB   rM   rU   ry   r\   r^   re   r   r   r   r‡   r   r   rŒ   r   r'   r'   r'   r(   Ú<module>   sœ   
   	







 

ûþýüûúúÿþýüûú
ù (