a Rel8 @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_SCHEMES unix_userplatlibFz $usersite)distutils.command.installr#KeyError)r#unix_user_platlibr)/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/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..) unix_prefix unix_home)r&r#allr)r)r"r*_looks_like_red_hat_libKs  r=cCsddlm}d|vod|vS)z#Debian adds two additional schemes.rr" deb_system unix_local)r&r#r"r)r)r*_looks_like_debian_schemeZs r@cCs^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&rAdistutils.distrBfinalize_options exec_prefixospathnormpathr0prefix)rArBcmdr)r)r*_looks_like_red_hat_schemebs   rKcs.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)Librz site-packagesN)endswith)r7pr)r)r*r9sz1_looks_like_msys2_mingw_scheme..c3s|]}|VqdSr5r))r7keypathsr)r*r9r%r.) sysconfig get_pathsr<r)r)rRr*_looks_like_msys2_mingw_schemevs rX)partsr!ccshtd}ttdd}|r(|r(||s6|EdHdS|D](}||r\|ddt|}|Vq:dS)N LDVERSIONabiflagsr)rVget_config_vargetattrr0rOlen)rY ldversionr[partr)r)r* _fix_abiflagss    ra)oldnewrQr!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)rbrcrQ issue_urlmessager)r)r*_warn_mismatchedsricCs||kr dSt|||ddS)NFrQT)ri)rbrcrQr)r)r*_warn_if_mismatchsrkFuserhomerootrI)rmrnrorIr!cCs&gd}ttd|||||dS)N)zAdditional context:z user = %rz home = %rz root = %rz prefix = %r )rdrerfjoin)rmrnrorIrYr)r)r* _log_contextsrr) dist_namermrnroisolatedrIr!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)reason replacementgone_inrjrl)#rr_USE_SYSCONFIGrrpathlibPathr]r0implementationnameparent startswithrr=r version_inforr+r rYr^rKr@tuplerarXrVis_python_buildappenddistutils_schemeanyr rirr)rsrmrnrortrIrcwarning_contextsr8old_vnew_vskip_pypy_special_case$skip_osx_framework_user_special_caseskip_bpo_44860skip_linux_system_special_caseskip_sysconfig_abiflag_bugskip_msys2_mingw_bugskip_cpython_buildrQr)rr*rs              rcCs<t}tr|St}tt|t|ddr8t|S)N bin_prefixrj)rrrrrkrrrrrcrbr)r)r*rdsrcCstjdddjS)NT)rm)rrscriptsr)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)r@)rr)r)r*$_looks_like_deb_system_dist_packagesss rcCsHt}tr|St}t|r$|Stt|t|ddrDt|S)z,Return the default pure-Python lib location.r.rj) rrrrrrkrrrrrr)r)r*rsrcCsHt}tr|St}t|r$|Stt|t|ddrDt|S)z0Return the default platform-shared lib location.r%rj) rrrrrrkrrrrrr)r)r*rsr)v1v2r!cCs||kr|gS||gS)zDeduplicate values from a list.r))rrr)r)r* _deduplicatedsr)rIr!cCszt|\}}trt||St|\}}tt|t|ddtt|t|ddg}t|rpt |dt||S)z*Return the lib locations under ``prefix``.zprefixed-purelibrjzprefixed-platlib)rI) rrrrrrkrrrrr)rInew_purenew_platold_pureold_platwarnedr)r)r*rs$   r)FNNFN)D functoolsloggingrFrr0rVtypingrrrrrrpip._internal.models.schemerr pip._internal.utils.compatr pip._internal.utils.deprecationr pip._internal.utils.virtualenvr rrrbaserrrrrr__all__ getLogger__name__rdenvirongetDEBUGrfWARNINGr]rstr__annotations__rrboolr+r3 lru_cacher=r@rKrXrarrirkrrrrrrrrrrr)r)r)r*s                 (