o ail8@sUddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZmZdd lmZmZmZmZmZmZgd Z e!e"Z#ej$%d rnej&Z'nej(Z'e)ed d Z*e+e,d<ej-dkZ.de/fddZ0dee+e+fde/fddZ1ej2ddde/fddZ3ej2ddde/fddZ4ej2ddde/fddZ5ej2ddde/fddZ6de e+de e+fd d!Z7ej2ddd"ej8d#ej8d$e+ddfd%d&Z9d"ej8d#ej8d$e+de/fd'd(Z:ej2ddd)dddd*d+e/d,e e+d-e e+d.e e+ddf d/d0Z; )   ) dFd1e+d+e/d,e e+d-e e+d2e/d.e e+defd3d4Zd9e+de/fd:d;Z?de+fdd?ZAd@e+dAe+de e+fdBdCZBd.e+de e+fdDdEZCdS)GN)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) returncCs8ddlm}z |dd}W|dkStyYdSw)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-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/locations/__init__.py_looks_like_bpo_448603s  r+schemecCs\|d}d|vrttdr|ddtjd}d|vrdS|dd}|dd |d kS) Nr%z /$platlibdir/r/z/lib64/Fz/lib/z $platbase/z$base/purelib)hasattrsysreplacer)r,r% unpatchedr)r)r*+_looks_like_red_hat_patched_platlib_purelibAs r3)maxsizecs"ddlmtfdddDS)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. rr"c3s$|] }|vo t|VqdSN)r3.0kr"r)r* Ss   z*_looks_like_red_hat_lib..) unix_prefix unix_home)r&r#allr)r)r"r*_looks_like_red_hat_libKs  r=cCsddlm}d|vo d|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|vod|vo|d VqdS)Librz site-packagesN)endswith)r7pr)r)r*r9s  z1_looks_like_msys2_mingw_scheme..c3s|]}|VqdSr5r))r7keypathsr)r*r9sr%r.) sysconfig get_pathsr<r)r)rRr*_looks_like_msys2_mingw_schemevs rWpartsccsjtd}ttdd}|r|r||s|EdHdS|D]}||r/|ddt|}|VqdS)N LDVERSIONabiflagsr)rUget_config_vargetattrr0rOlen)rX ldversionrZpartr)r)r* _fix_abiflagss    r`oldnewrQcCs 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)rarbrQ issue_urlmessager)r)r*_warn_mismatchedsrhcCs||krdSt|||ddS)NFrQT)rh)rarbrQr)r)r*_warn_if_mismatchsrjFuserhomerootrIrlrmrnrIcCs&gd}ttd|||||dS)N)zAdditional context:z user = %rz home = %rz root = %rz prefix = %r )rcrdrejoin)rlrmrnrIrXr)r)r* _log_contextsrq dist_nameisolatedc stj||||||d}tr|Stj||||||dg}tD]}tt|} tt||} | | kr5qtj j dkoT|duoT|dvoT| j | j koT| j doT| j d} | rXq|ont on|dkon| j j | j kon| j j d} | rrq|dkrztrzq|o|dkot otjdkotdkot} | rq|p|p|pt o| jd d d kot| jd ko| jd d kot| jd kp| jd dkotpt}|rqtjdkot o|dvott| j| jk}|rqto|dvot}|rqtjddot o|dv}|rq|| | d|fq|sStj||||||ddtfddtDr2t ddddS|D] \} } }t!| | |dq4t"||||dS)N)rlrmrnrsrIpypyrTpythonheadersr%)r rr r)usrlocalrxry)r)rvr%r.T) check_home)rvinclude platincludezscheme.)ignore_config_filesc3s"|] }|t|kVqdSr5)r\r6 default_oldrar)r*r9Os zget_scheme..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_inrirk)#rr_USE_SYSCONFIGrrpathlibPathr\r0implementationnameparent startswithrr=r version_inforr+r rXr]rKr@tupler`rWrUis_python_buildappenddistutils_schemeanyr rhrq)rrrlrmrnrsrIrbwarning_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|ddrt|S)N bin_prefixri)rrrrrjrrrqrbrar)r)r*rdsrcCstjdddjS)NT)rl)rrscriptsr)r)r)r*rosrvaluecCstsdS|dkr dSdS)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  rcCHt}tr|St}t|r|Stt|t|ddr"t|S)z,Return the default pure-Python lib location.r.ri) rrrrrrjrrrqrr)r)r*rrcCr)z0Return the default platform-shared lib location.r%ri) rrrrrrjrrrqrr)r)r*rrrv1v2cCs||kr|gS||gS)zDeduplicate values from a list.r))rrr)r)r* _deduplicatedsrcCszt|\}}trt||St|\}}tt|t|ddtt|t|ddg}t|r8t |dt||S)z*Return the lib locations under ``prefix``.zprefixed-purelibrizprefixed-platlib)rI) rrrrrrjrrrrq)rInew_purenew_platold_pureold_platwarnedr)r)r*rs$   r)FNNFN)D functoolsloggingrFrr0rUtypingrrrrrrpip._internal.models.schemerr pip._internal.utils.compatr pip._internal.utils.deprecationr pip._internal.utils.virtualenvr rrrbaserrrrrr__all__ getLogger__name__rcenvirongetDEBUGreWARNINGr\rstr__annotations__rrboolr+r3 lru_cacher=r@rKrWr`rrhrjrqrrrrrrrrr)r)r)r*s                  (