a [fl8 @sUddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZmZdd lmZmZmZmZmZmZgd Z e!e"Z#ej$%d rej&Z'nej(Z'e)ed d Z*e+e,d<ej-dkZ.e/dddZ0ee+e+fe/dddZ1ej2dde/dddZ3ej2dde/dddZ4ej2dde/dddZ5ej2dde/dddZ6e e+e e+dd d!Z7ej2ddej8ej8e+dd"d#d$Z9ej8ej8e+e/d"d%d&Z:ej2ddd'dddd(e/e e+e e+e e+dd)d*d+Z;d@e+e/e e+e e+e/e e+ed,d-d.Ze+e/d3d4d5Z?e+dd6d7Z@e+dd8d9ZAe+e+e e+d:d;d<ZBe+e e+d=d>d?ZCdS)AN)AnyDictIteratorListOptionalTuple) SCHEME_KEYSScheme)WINDOWS) deprecated)running_under_virtualenv) _distutils _sysconfig)USER_CACHE_DIRget_major_minor_versionget_src_prefixis_osx_framework site_packages user_site) rget_bin_prefix get_bin_userr get_platlibget_prefixed_libs get_purelib get_schemerrrZ"_PIP_LOCATIONS_NO_WARN_ON_MISMATCH platlibdirlib _PLATLIBDIR) )returncCs:ddlm}z|dd}Wnty0YdS0|dkS)zsThe resolution to bpo-44860 will change this incorrect platlib. See . rINSTALL_SCHEMESZ unix_userplatlibFz $usersite)distutils.command.installr#KeyError)r#Zunix_user_platlibr'D/usr/lib/python3.9/site-packages/pip/_internal/locations/__init__.py_looks_like_bpo_448603s   r))schemer!cCs\|d}d|vr0ttdr0|ddtjd}d|vrSsz*_looks_like_red_hat_lib..)Z unix_prefixZ unix_home)r%r#allr'r'r"r(_looks_like_red_hat_libKs  r8cCsddlm}d|vod|vS)z#Debian adds two additional schemes.rr"Z deb_systemZ unix_local)r%r#r"r'r'r(_looks_like_debian_schemeZs r9cCs^ddlm}ddlm}||}||jtjt jdko\|j tjt j dkS)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:Zdistutils.distr;Zfinalize_options exec_prefixospathnormpathr.prefix)r:r;cmdr'r'r(_looks_like_red_hat_schemebs   rBcs.tjdddtddfdddDDS)aMSYS2 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)expandcss*|]"}d|vo d|vo |d VqdS)ZLibrz site-packagesN)endswith)r4pr'r'r(r6sz1_looks_like_msys2_mingw_scheme..c3s|]}|VqdSr2r')r4keypathsr'r(r6r$r,) sysconfigZ get_pathsr7r'r'rHr(_looks_like_msys2_mingw_schemevs rM)partsr!ccshtd}ttdd}|r(|r(||s6|EdHdS|D](}||r\|ddt|}|Vq:dS)NZ LDVERSIONabiflagsr)rLZget_config_vargetattrr.rElen)rNZ ldversionrOpartr'r'r( _fix_abiflagss    rS)oldnewrGr!cCs d}d}tt|||||dS)Nz(https://github.com/pypa/pip/issues/10151zSValue for %s does not match. Please report this to <%s> distutils: %s sysconfig: %s)loggerlog_MISMATCH_LEVEL)rTrUrGZ issue_urlmessager'r'r(_warn_mismatchedsrZcCs||kr dSt|||ddS)NFrGT)rZ)rTrUrGr'r'r(_warn_if_mismatchsr\Fuserhomerootr@)r^r_r`r@r!cCs&gd}ttd|||||dS)N)zAdditional context:z user = %rz home = %rz root = %rz prefix = %r )rVrWrXjoin)r^r_r`r@rNr'r'r( _log_contextsrc) dist_namer^r_r`isolatedr@r!c stj||||||d}tr|Stj||||||dg}tD]}tt|} tt||} | | krlq.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)reasonZ replacementZgone_inr[r])#rr_USE_SYSCONFIGrrpathlibPathrPr.implementationnameparent startswithrr8r version_inforr)r rNrQrBr9tuplerSrMrLZis_python_buildappendZdistutils_schemeanyr rZrc)rdr^r_r`rer@rUZwarning_contextsr5Zold_vZnew_vZskip_pypy_special_caseZ$skip_osx_framework_user_special_caseZskip_bpo_44860Zskip_linux_system_special_caseZskip_sysconfig_abiflag_bugZskip_msys2_mingw_bugZskip_cpython_buildrGr'rlr(rs              rcCs<t}tr|St}tt|t|ddr8t|S)NZ bin_prefixr[)rrrnrr\rorprcrUrTr'r'r(rdsrcCstjdddjS)NT)r^)rrZscriptsr'r'r'r(rosr)valuer!cCsts dS|dkrdSdS)aCheck 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_packagesss r|cCsHt}tr|St}t|r$|Stt|t|ddrDt|S)z,Return the default pure-Python lib location.r,r[) rrrnrr|r\rorprcryr'r'r(rsrcCsHt}tr|St}t|r$|Stt|t|ddrDt|S)z0Return the default platform-shared lib location.r$r[) rrrnrr|r\rorprcryr'r'r(rsr)v1v2r!cCs||kr|gS||gS)zDeduplicate values from a list.r')r}r~r'r'r( _deduplicatedsr)r@r!cCszt|\}}trt||St|\}}tt|t|ddtt|t|ddg}t|rpt |dt||S)z*Return the lib locations under ``prefix``.zprefixed-purelibr[zprefixed-platlib)r@) rrrnrrr\rorprxrc)r@Znew_pureZnew_platZold_pureZold_platZwarnedr'r'r(rs$   r)FNNFN)D functoolsZloggingr=ror.rLtypingrrrrrrZpip._internal.models.schemerr Zpip._internal.utils.compatr Zpip._internal.utils.deprecationr Zpip._internal.utils.virtualenvr rzrrbaserrrrrr__all__Z getLogger__name__rVenvirongetDEBUGrXZWARNINGrPrstr__annotations__rurnboolr)r0 lru_cacher8r9rBrMrSrprZr\rcrrrr|rrrrr'r'r'r(s                 (