a  ze3 @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<e-dddZ.ee+e+fe-dddZ/ej0dde-dddZ1ej0dde-dddZ2ej0dde-dddZ3ej0dde-dddZ4e e+e e+ddd Z5ej0ddej6ej6e+dd!d"d#Z7ej6ej6e+e-d!d$d%Z8ej0ddd&dddd'e-e e+e e+e e+dd(d)d*Z9de+dd7d8Z?e+e e+d9d:d;Z@dS)=N)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'b/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/locations/__init__.py_looks_like_bpo_448601s   r))schemercCs4|d}d|vrdS|dd}|dd|dkS)Nr#z/lib64/Fz/lib/z $platbase/z$base/purelib)replace)r*r# unpatchedr'r'r(+_looks_like_red_hat_patched_platlib_purelib?s  r.)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"|]}|vot|VqdSN)r..0kr r'r( Osz*_looks_like_red_hat_lib..) unix_prefix unix_home)r$r!allr'r'r r(_looks_like_red_hat_libGs  r8cCsddlm}d|vod|vS)z#Debian adds two additional schemes.rr deb_system unix_local)r$r!r r'r'r(_looks_like_debian_schemeVs 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$r<distutils.distr=finalize_options exec_prefixospathnormpathsysprefix)r<r=cmdr'r'r(_looks_like_red_hat_scheme^s   rGcs.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)r2pr'r'r(r4~sz1_looks_like_msys2_mingw_scheme..c3s|]}|VqdSr0r')r2keypathsr'r(r4r#r+) sysconfig get_pathsr7r'r'rNr(_looks_like_msys2_mingw_schemers rT)partsrccshtd}ttdd}|r(|r(||s6|EdHdS|D](}||r\|ddt|}|Vq:dS)N LDVERSIONabiflagsr)rRget_config_vargetattrrDrKlen)rU ldversionrWpartr'r'r( _fix_abiflagss    r])oldnewrMrcCs 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)r^r_rM issue_urlmessager'r'r(_warn_mismatchedsrecCs||kr dSt|||ddS)NFrMT)re)r^r_rMr'r'r(_warn_if_mismatchsrgFuserhomerootrE)rirjrkrErcCs&gd}ttd|||||dS)N)zAdditional context:z user = %rz home = %rz root = %rz prefix = %r )r`rarbjoin)rirjrkrErUr'r'r( _log_contextsrn) dist_namerirjrkisolatedrErc stj||||||dtj||||||d}g}tD]}tt|} tt||} | | krdq4tjj dko|duo|dvo| j | j ko| j do| j d} | rq4|ot o|dko| j j | j ko| j j d} | rq4|dkrt rq4|o |dko t o tjdko tdko t} | r*q4|p@|p@|p@t o| jd d d kot| jd ko| jd d kot| jd ks| jd dkotpt}|rq4tjdkot o|dvott| j| jk}|rq4to|dvot}|rq4|| | d|fq4|s*Stj||||||ddtfddtDrntddddS|D]\} } }t| | |dqrt||||dS)N)rirjrkrprEpypyrQpythonheadersr#) rr rt)usrlocalrvrw)rt)rsr#r+zscheme.T)ignore_config_filesc3s |]}|t|kVqdSr0)rYr1 default_oldr^r'r(r4<rPzget_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) replacementgone_inrfrh) rrrrpathlibPathrYrDimplementationnameparent startswithrr8r version_inforr)r rUrZrGr;tupler]rTappenddistutils_schemeanyr rern)rorirjrkrprEr_warning_contextsr3old_vnew_vskip_pypy_special_case$skip_osx_framework_user_special_caseskip_bpo_44860skip_linux_system_special_caseskip_sysconfig_abiflag_bugskip_msys2_mingw_bugrMr'r{r(rs             rcCs4t}t}tt|t|ddr0t|S)N bin_prefixrf)rrrrgrrrnr^r_r'r'r(rOs rcCstjdddjS)NT)ri)rrscriptsr'r'r'r(rWsr)valuercCsts 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_packages[s rcCs@t}t}t|r|Stt|t|ddrs