U ʗRe5D @s UddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZdd lmZmZmZmZmZmZd d d d dddddddg Ze e!Z"e#eddZ$e%e&d<ej'dkZ(e)dddZ*e*Z+e(re+sej,Z-nej.Z-e)dddZ/ee%e%fe)ddd Z0ej1dd!e)dd"d#Z2ej1dd!e)dd$d%Z3ej1dd!e)dd&d'Z4ej1dd!e)dd(d)Z5ej1dd!e)dd*d+Z6e e%e e%ddfd,d-d.Z7ej1dd!ej8ej8e%dd/d0d1Z9ej8ej8e%e)d/d2d3Z:ej1dd!d4dddd5e)e e%e e%e e%dd6d7d8Z;dJe%e)e e%e e%e)e e%ed9d:dZe%e)d=d>d?Z?e%dd@dZ@e%ddAdZAe%e%e e%dBdCdDZBe%e)dEdFdGZCe%e e%dHdIdZDdS)KN)AnyDict GeneratorListOptionalTuple) SCHEME_KEYSScheme)WINDOWS) deprecated)running_under_virtualenv) _sysconfig)USER_CACHE_DIRget_major_minor_versionget_src_prefixis_osx_framework site_packages user_siterget_bin_prefix get_bin_userr get_platlibget_prefixed_libs get_purelib get_schemerrrZ 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%/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/locations/__init__.py_should_use_sysconfig/s r'cCs<ddlm}z|dd}Wntk r2YdSX|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%r%r&_looks_like_bpo_44860Gs  r/)schemercCsP|d}d|kr$|ddtd}d|kr0dS|dd}|dd|d kS) Nr+z /$platlibdir///lib64/Fz/lib/z $platbase/z$base/purelib)replacer)r0r+ unpatchedr%r%r&+_looks_like_red_hat_patched_platlib_purelibUs r6)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"|]}|kot|VqdSN)r6.0kr(r%r& gsz*_looks_like_red_hat_lib..) unix_prefix unix_home)r,r)allr%r%r(r&_looks_like_red_hat_lib_s  r@cCsddlm}d|kod|kS)z#Debian adds two additional schemes.rr( deb_system unix_local)r,r)r(r%r%r&_looks_like_debian_schemens rCcCs^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,rDdistutils.distrEfinalize_options exec_prefixospathnormpathsysprefix)rDrEcmdr%r%r&_looks_like_red_hat_schemevs   rOcCsJtdkr dSztjddd}Wntk r4YdSXd|dkoHdtkS)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)r0expandr2r3)rr# get_pathsr-pathsr%r%r&_looks_like_slackware_schemesrUcs.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)rQcss*|]"}d|ko d|ko |d VqdS)Librz site-packagesN)endswithr:pr%r%r&r<sz1_looks_like_msys2_mingw_scheme..c3s|]}|VqdSr8r%)r:keyrSr%r&r<sr+r3)r#rRr?r%r%rSr&_looks_like_msys2_mingw_schemes r])partsrccshtd}ttdd}|r(|r(||s6|EdHdS|D](}||r\|ddt|}|Vq:dS)N LDVERSIONabiflagsr)r#get_config_varr"rLrXlen)r^ ldversionr`partr%r%r& _fix_abiflagss    re)oldnewr[rcCs 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)rfrgr[ issue_urlmessager%r%r&_warn_mismatchedsrmcCs||kr dSt|||ddS)NFr[T)rm)rfrgr[r%r%r&_warn_if_mismatchsroFuserhomerootrM)rqrrrsrMrcCs,dddddg}ttd|||||dS)NzAdditional context:z user = %rz home = %rz root = %rz prefix = %r )rhrirjjoin)rqrrrsrMr^r%r%r& _log_contexts rv) dist_namerqrrrsisolatedrMrc stj||||||d}tr|Sddlm}|j||||||dg}tD]8} tt| } tt|| } | | krxqHt j j dko|dk o| dko| j | j ko| j do| j d} | rqH|oto| dko| j j | j ko| j j d} | rqH| dkrtrqH|o8| dko8t o8t jd ko8td ko8t}|rBqH|o^| dko^t o^t}|rhqH|p~|p~|p~t o| jdd d kot| jdko| jdd kot| jd ks| jddkotpt}|rqHt jdkot o| dkott| j| jk}|r(qHto<| dko.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_inrnrp)%rr_USE_SYSCONFIGrzrpathlibPathr"rLimplementationnameparent startswithrr@r version_inforr/rUr r^rbrOrCtuplerer]r#is_python_buildappenddistutils_schemeanyr rmrv)rwrqrrrsrxrMrgrzwarning_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               cCsHt}tr|Sddlm}|}tt|t|ddrDt|S)Nr ry bin_prefixrn) rrrrrzrorrrvrgrzrfr%r%r&rs cCstjdddjS)NrT)rq)rrscriptsr%r%r%r&rs)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)rC)rr%r%r&$_looks_like_deb_system_dist_packagess rcCsTt}tr|Sddlm}|}t|r0|Stt|t|ddrPt |S)z,Return the default pure-Python lib location.r ryr3rn) rrrrrzrrorrrvrr%r%r&rs cCsTt}tr|Sddlm}|}t|r0|Stt|t|ddrPt |S)z0Return the default platform-shared lib location.r ryr+rn) rrrrrzrrorrrvrr%r%r&rs )v1v2rcCs||kr|gS||gS)zDeduplicate values from a list.r%)rrr%r%r& _deduplicatedsr)rJrcCs(tjdddkrdS|dtdkS)zAApple patches sysconfig to *always* look under */Library/Python*.NdarwinFz/Library/Python/z/site-packages)rLplatformr)rJr%r%r&_looks_like_apple_librarysr)rMrcCst|\}}trt||Sddlm}||\}}t||}tdd|Drdtdddd|Stt |t |dd tt |t |d d g}t |rt |d |S) z*Return the lib locations under ``prefix``.r rycss|]}t|VqdSr8)rrYr%r%r&r<sz$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-purelibrnzprefixed-platlib)rM) rrrrrrzr?r rorrrrv)rMnew_purenew_platrzold_pureold_plat old_lib_pathswarnedr%r%r&rs6      )FNNFN)E functoolsloggingrIrrLr#typingrrrrrrpip._internal.models.schemerr pip._internal.utils.compatr pip._internal.utils.deprecationr pip._internal.utils.virtualenvr rrbaserrrrrr__all__ getLogger__name__rhr"rstr__annotations__rr$r!r'rWARNINGrjDEBUGr/r6 lru_cacher@rCrOrUr]rerrmrorvrrrrrrrrrr%r%r%r&s                  5