o
    5dD                     @   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 dd	lmZmZmZmZmZmZ g d
Ze e!Z"e#eddZ$e%e&d< ej'dkZ(de)fddZ*e* Z+e+sddlm,Z, e(re+sej-Z.nej/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 Z6e j2ddde)fd!d"Z7d#ee% de	e%ddf fd$d%Z8e j2ddd&ej9d'ej9d(e%ddfd)d*Z:d&ej9d'ej9d(e%de)fd+d,Z;e j2ddd-dddd.d/e)d0ee% d1ee% d2ee% ddf
d3d4Z<	-			-	dMd5e%d/e)d0ee% d1ee% d6e)d2ee% defd7d8Z=de%fd9d:Z>de%fd;d<Z?d=e%de)fd>d?Z@de%fd@dAZAde%fdBdCZBdDe%dEe%de
e% fdFdGZCdHe%de)fdIdJZDd2e%de
e% fdKdLZEdS )N    N)AnyDict	GeneratorListOptionalTuple)SCHEME_KEYSScheme)WINDOWS)
deprecated)running_under_virtualenv   )
_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   
platlibdirlib_PLATLIBDIR)   
   returnc                   C   s   t ttdtS )ax  This function determines the value of _USE_SYSCONFIG.

    By default, pip uses sysconfig on Python 3.10+.
    But Python distributors can override this decision by setting:
        sysconfig._PIP_USE_SYSCONFIG = True / False
    Rationale in https://github.com/pypa/pip/issues/10647

    This is a function for testability, but should be constant during any one
    run.
    _PIP_USE_SYSCONFIG)boolgetattr	sysconfig_USE_SYSCONFIG_DEFAULT r&   r&   wC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\pip/_internal/locations/__init__.py_should_use_sysconfig/   s   r(   
_distutilsc                  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_SCHEMES	unix_userplatlibFz	$usersite)distutils.command.installr,   KeyError)r,   unix_user_platlibr&   r&   r'   _looks_like_bpo_44860M   s   r2   schemec                 C   sP   | d }d|v r| ddt d}d|vrdS | dd}| dd| d	 kS )
Nr.   z/$platlibdir///lib64/Fz/lib/z
$platbase/z$base/purelib)replacer   )r3   r.   	unpatchedr&   r&   r'   +_looks_like_red_hat_patched_platlib_purelib[   s   r9   )maxsizec                      s"   ddl m  t fdddD S )zRed 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)r9   .0kr+   r&   r'   	<genexpr>m   s    

z*_looks_like_red_hat_lib.<locals>.<genexpr>)unix_prefix	unix_home)r/   r,   allr&   r&   r+   r'   _looks_like_red_hat_libe   s   rC   c                  C   s   ddl m}  d| v od| v S )z#Debian adds two additional schemes.r   r+   
deb_system
unix_local)r/   r,   r+   r&   r&   r'   _looks_like_debian_schemet   s   rF   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/   rG   distutils.distrH   finalize_optionsexec_prefixospathnormpathsysprefix)rG   rH   cmdr&   r&   r'   _looks_like_red_hat_scheme|   s   	
rR   c                  C   sH   t du rdS z	tjddd} W n
 ty   Y dS w d| d v o#dt vS )zSlackware patches sysconfig but fails to patch distutils and site.

    Slackware changes sysconfig's user scheme to use ``"lib64"`` for the lib
    path, but does not do the same to the site module.
    NF
posix_user)r3   expandr5   r6   )r   r$   	get_pathsr0   pathsr&   r&   r'   _looks_like_slackware_scheme   s   rX   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)rT   c                 s   s,    | ]}d |vod|v o| d V  qdS )Libr   zsite-packagesN)endswithr=   pr&   r&   r'   r?      s
    
z1_looks_like_msys2_mingw_scheme.<locals>.<genexpr>c                 3   s    | ]} | V  qd S r;   r&   )r=   keyrV   r&   r'   r?          r.   r6   )r$   rU   rB   r&   r&   rV   r'   _looks_like_msys2_mingw_scheme   s   ra   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   )r$   get_config_varr#   rO   r[   len)rb   	ldversionrd   partr&   r&   r'   _fix_abiflags   s   


ri   oldnewr^   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)rj   rk   r^   	issue_urlmessager&   r&   r'   _warn_mismatched   s   rq   c                C   s   | |krdS t | ||d dS )NFr^   T)rq   )rj   rk   r^   r&   r&   r'   _warn_if_mismatch   s   rs   FuserhomerootrP   ru   rv   rw   rP   c                 C   s&   g d}t td|| ||| d S )N)zAdditional context:z	user = %rz	home = %rz	root = %rzprefix = %r
)rl   rm   rn   join)ru   rv   rw   rP   rb   r&   r&   r'   _log_context   s   rz   	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ot otjdkotdkot }|rq|o|dv ot ot }|rq|p|p|pt  o|	jd	d
 dkot|
jd	ko|
jd	 dkot|
jd
k p|
jd dkot pt }|rqtjdk ot o|dv ott|	j|
jk}|rqto|dv ot }|rq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 rDt!dd d d S |D ]\}	}
}t"|	|
|d qFt#||||d S )N)ru   rv   rw   r|   rP   pypyr`   pythonheadersr.   )r   	   r   r   r   )usrlocalr      r   )r      )r   r.   r6   T)
check_home)r   includeplatincludezscheme.)ignore_config_filesc                 3   s"    | ]} | t |kV  qd S r;   )r#   r<   default_oldrj   r&   r'   r?     s     zget_scheme.<locals>.<genexpr>zConfiguring 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_inrr   rt   )$r   r   _USE_SYSCONFIGr*   r   pathlibPathr#   rO   implementationnameparent
startswithr   rC   r
   version_infor   r2   rX   r   rb   rf   rR   rF   tupleri   ra   r$   is_python_buildappenddistutils_schemeanyr   rq   rz   )r{   ru   rv   rw   r|   rP   rk   warning_contextsr>   old_vnew_vskip_pypy_special_case$skip_osx_framework_user_special_caseskip_bpo_44860skip_slackware_user_schemeskip_linux_system_special_caseskip_sysconfig_abiflag_bugskip_msys2_mingw_bugskip_cpython_buildr^   r&   r   r'   r      s   	




	
r   c                  C   s<   t  } tr| S t }tt|t| ddrt  |S )N
bin_prefixrr   )r   r   r   r*   rs   r   r   rz   rk   rj   r&   r&   r'   r     s   r   c                   C   s   t jdddjS )N T)ru   )r   r   scriptsr&   r&   r&   r'   r     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)rF   )r   r&   r&   r'   $_looks_like_deb_system_dist_packages  s
   
r   c                  C   sH   t  } tr| S t }t|r|S tt|t| ddr"t  |S )z,Return the default pure-Python lib location.r6   rr   )	r   r   r   r*   r   rs   r   r   rz   r   r&   r&   r'   r     s   r   c                  C   sT   t  } tr| S ddlm} | }t|r|S tt|t| ddr(t	  |S )z0Return the default platform-shared lib location.r   r)   r.   rr   )
r   r   r   r   r*   r   rs   r   r   rz   )rk   r*   rj   r&   r&   r'   r     s   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   rM   c                 C   s(   t jdd dkrdS | dt  dkS )zAApple patches sysconfig to *always* look under */Library/Python*.N   darwinFz/Library/Python/z/site-packages)rO   platformr   )rM   r&   r&   r'   _looks_like_apple_library  s   r   c                 C   s   t | \}}trt||S t| \}}t||}tdd |D r,tdddd |S tt	|t	|ddtt	|t	|ddg}t
|rOt| d	 |S )
z*Return the lib locations under ``prefix``.c                 s   s    | ]}t |V  qd S r;   )r   r\   r&   r&   r'   r?     r_   z$get_prefixed_libs.<locals>.<genexpr>a&  Python distributed by Apple's Command Line Tools incorrectly patches sysconfig to always point to '/Library/Python'. This will cause build isolation to operate incorrectly on Python 3.10 or later. Please help report this to Apple so they can fix this. https://developer.apple.com/bug-reporting/Nr   zprefixed-purelibrr   zprefixed-platlib)rP   )r   r   r   r   r*   rB   r   rs   r   r   r   rz   )rP   new_purenew_platold_pureold_platold_lib_pathswarnedr&   r&   r'   r     s4   


r   )FNNFN)F	functoolsloggingrL   r   rO   r$   typingr   r   r   r   r   r   pip._internal.models.schemer   r	   pip._internal.utils.compatr
   pip._internal.utils.deprecationr   pip._internal.utils.virtualenvr   r   r   baser   r   r   r   r   r   __all__	getLogger__name__rl   r#   r   str__annotations__r   r%   r"   r(   r   r*   WARNINGrn   DEBUGr2   r9   	lru_cacherC   rF   rR   rX   ra   ri   r   rq   rs   rz   r   r   r   r   r   r   r   r   r   r&   r&   r&   r'   <module>   s   
   	







 
 


 3