o 7]hC@s,UddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZmZdd lmZmZmZmZmZmZgd Z e!e"Z#e$ed d Z%e&e'd <ej(dkZ)de*fddZ+e+Z,e)re,sej-Z.nej/Z.de*fddZ0dee&e&fde*fddZ1ej2ddde*fddZ3ej2ddde*fddZ4ej2ddde*fddZ5ej2ddde*fddZ6ej2ddde*fd d!Z7d"e e&de e&fd#d$Z8ej2ddd%ej9d&ej9d'e&ddfd(d)Z:d%ej9d&ej9d'e&de*fd*d+Z;ej2ddd,dddd-d.e*d/e e&d0e e&d1e e&ddf d2d3Z< ,   , dLd4e&d.e*d/e e&d0e e&d5e*d1e e&defd6d7Z=de&fd8d9Z>de&fd:d;Z?dZ@de&fd?d@ZAde&fdAdBZBdCe&dDe&de e&fdEdFZCdGe&de*fdHdIZDd1e&de e&fdJdKZEdS)MN)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_schemerrr platlibdirlib _PLATLIBDIR) returncCstttdtS)axThis 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)boolgetattr sysconfig_USE_SYSCONFIG_DEFAULTr'r'B/usr/lib/python3/dist-packages/pip/_internal/locations/__init__.py_should_use_sysconfig/s r)cCs8ddlm}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'r'r(_looks_like_bpo_44860Gs  r1schemecCsP|d}d|vr|ddtd}d|vrdS|dd}|dd|d kS) Nr-z /$platlibdir///lib64/Fz/lib/z $platbase/z$base/purelib)replacer)r2r- unpatchedr'r'r(+_looks_like_red_hat_patched_platlib_purelibUs r8)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)r8.0kr*r'r( gs   z*_looks_like_red_hat_lib..) unix_prefix unix_home)r.r+allr'r'r*r(_looks_like_red_hat_lib_s  rBcCsddlm}d|vo d|vS)z#Debian adds two additional schemes.rr* deb_system unix_local)r.r+r*r'r'r(_looks_like_debian_schemens rEcCs^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.rFdistutils.distrGfinalize_options exec_prefixospathnormpathsysprefix)rFrGcmdr'r'r(_looks_like_red_hat_schemevs  rQcCsHtdurdSz tjddd}Wn tyYdSwd|dvo#dtvS)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)r2expandr4r5)rr% get_pathsr/pathsr'r'r(_looks_like_slackware_schemes rWcs.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)rScss,|]}d|vod|vo|d VqdS)Librz site-packagesN)endswithr<pr'r'r(r>s  z1_looks_like_msys2_mingw_scheme..c3s|]}|VqdSr:r')r<keyrUr'r(r>r-r5)r%rTrAr'r'rUr(_looks_like_msys2_mingw_schemes r`partsccsjtd}ttdd}|r|r||s|EdHdS|D]}||r/|ddt|}|VqdS)N LDVERSIONabiflagsr)r%get_config_varr$rNrZlen)ra ldversionrcpartr'r'r( _fix_abiflagss    rholdnewr]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)rirjr] issue_urlmessager'r'r(_warn_mismatchedsrpcCs||krdSt|||ddS)NFr]T)rp)rirjr]r'r'r(_warn_if_mismatchsrrFuserhomerootrOrtrurvrOcCs&gd}ttd|||||dS)N)zAdditional context:z user = %rz home = %rz root = %rz prefix = %r )rkrlrmjoin)rtrurvrOrar'r'r( _log_contextsry 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|o|dvot ot}|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}|rqtjddo t o |dv}|rq|| | d|fq|s"Stj||||||ddt fddtDrDt!ddddS|D] \} } }t"| | |dqFt#||||dS)N)rtrurvr{rOpypyr_pythonheadersr-)r rr r)usrlocalrr)r)r~r-r5T) check_home)r~include platincludezscheme.)ignore_config_filesc3s"|] }|t|kVqdSr:)r$r; default_oldrir'r(r>~s 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/76621reason replacementgone_inrqrs)$rr_USE_SYSCONFIGrrpathlibPathr$rNimplementationnameparent startswithrrBr version_inforr1rWr rarerQrEtuplerhr`r%is_python_buildappenddistutils_schemeanyr rpry)rzrtrurvr{rOrjwarning_contextsr=old_vnew_vskip_pypy_special_case$skip_osx_framework_user_special_caseskip_bpo_44860skip_slackware_user_schemeskip_linux_system_special_caseskip_sysconfig_abiflag_bugskip_msys2_mingw_bugskip_cpython_buildr]r'rr(rs             rcCs<t}tr|St}tt|t|ddrt|S)N bin_prefixrq)rrrrrrrrryrjrir'r'r(rsrcCstjdddjS)NT)rt)rrscriptsr'r'r'r(rsrvaluecCstsdS|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)rE)rr'r'r($_looks_like_deb_system_dist_packagess  rcCHt}tr|St}t|r|Stt|t|ddr"t|S)z,Return the default pure-Python lib location.r5rq) rrrrrrrrrryrr'r'r(rrcCr)z0Return the default platform-shared lib location.r-rq) rrrrrrrrrryrr'r'r(rrrv1v2cCs||kr|gS||gS)zDeduplicate values from a list.r')rrr'r'r( _deduplicatedsrrLcCs(tjdddkr dS|dtdkS)zAApple patches sysconfig to *always* look under */Library/Python*.NdarwinFz/Library/Python/z/site-packages)rNplatformr)rLr'r'r(_looks_like_apple_librarysrcCst|\}}trt||St|\}}t||}tdd|Dr,tdddd|Stt |t |ddtt |t |ddg}t |rOt |d |S) z*Return the lib locations under ``prefix``.css|]}t|VqdSr:)rr[r'r'r(r>r^z$get_prefixed_libs..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/Nrzprefixed-purelibrqzprefixed-platlib)rO) rrrrrrAr rrrrrry)rOnew_purenew_platold_pureold_plat old_lib_pathswarnedr'r'r(rs4    r)FNNFN)F functoolsloggingrKrrNr%typingrrrrrrpip._internal.models.schemerr pip._internal.utils.compatr pip._internal.utils.deprecationr pip._internal.utils.virtualenvr rrrbaserrrrrr__all__ getLogger__name__rkr$rstr__annotations__rr&r#r)rWARNINGrmDEBUGr1r8 lru_cacherBrErQrWr`rhrrprrryrrrrrrrrrr'r'r'r(s                  3