a [f @s\ddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z m Z ddl mZddlmZmZeeZeeZeeddZedd d Zedd d Zedd dZedddZgdZ e!ddure "dd eeej#eej#eeej#ee dddZ$edddZ%edddZ&edddZ'eej(eefdddZ)dS)!N)InvalidSchemeCombinationUserInstallationInvalid) SCHEME_KEYSScheme)running_under_virtualenv)get_major_minor_versionis_osx_frameworkZget_preferred_scheme)returncCsdtvot otS)aCheck for Apple's ``osx_framework_library`` scheme. Python distributed by Apple's Command Line Tools has this special scheme that's used when: * This is a framework build. * We are installing into the system prefix. This does not account for ``pip install --prefix`` (also means we're not installing to the system prefix), which should use ``posix_prefix``, but logic here means ``_infer_prefix()`` outputs ``osx_framework_library``. But since ``prefix`` is not available for ``sysconfig.get_default_scheme()``, which is the stdlib replacement for ``_infer_prefix()``, presumably Apple wouldn't be able to magically switch between ``osx_framework_library`` and ``posix_prefix``. ``_infer_prefix()`` returning ``osx_framework_library`` means its behavior is consistent whether we use the stdlib implementation or our own, and we deal with this special case in ``get_scheme()`` instead. osx_framework_library)_AVAILABLE_SCHEMESrr r r F/usr/lib/python3.9/site-packages/pip/_internal/locations/_sysconfig.py _should_use_osx_framework_prefixs rcCsvtr tdStrdStjjdtj}|tvr6|StjjtvrJtjjStjd}|tvrb|StjtvrrtjSdS)a!Try to find a prefix scheme for the current platform. This tries: * A special ``osx_framework_library`` for Python distributed by Apple's Command Line Tools, when not running in a virtual environment. * Implementation + OS, used by PyPy on Windows (``pypy_nt``). * Implementation without OS, used by PyPy on POSIX (``pypy``). * OS + "prefix", used by CPython on POSIX (``posix_prefix``). * Just the OS name, used by CPython on Windows (``nt``). If none of the above works, fall back to ``posix_prefix``. prefixr __prefix posix_prefix)_PREFERRED_SCHEME_APIrsysimplementationnameosr )Zimplementation_suffixedsuffixedr r r _infer_prefix8s   rcCsHtr tdStrtsd}n tjd}|tvr6|SdtvrDtdS)z3Try to find a user scheme for the current platform.userZosx_framework_user_userZ posix_user)rr rrrr rrr r r _infer_userWs  rcCs(tr tdStjd}|tvr$|SdS)z,Try to find a home for the current platform.home_homeZ posix_home)rrrr rr r r _infer_homefs  r!)Zinstalled_basebaseZinstalled_platbaseplatbaser exec_prefixuserbaseF) dist_namerrrootisolatedrr csb|rrtddr$r$tdddur4t}n|r@t}nt}durZ|dkrZd}durvfddtD}n durfd dtD}ni}tj||d }tr|r|d t j } n|d t j } d t } t j | dd| |d<n|sd}t|d|dt j |d||d|dd} |dur^tD]&} tj|t| | } t| | | q6| S)a\ Get the "scheme" corresponding to the input parameters. :param dist_name: the name of the package to retrieve the scheme for, used in the headers scheme path :param user: indicates to use the "user" scheme :param home: indicates to use the "home" scheme :param root: root under which other directories are re-based :param isolated: ignored, but kept for distutils compatibility (where this controls whether the user-site pydistutils.cfg is honored) :param prefix: indicates to use the "prefix" scheme and provides the base directory for the same z--userz--prefixz--homeNr rcsi|] }|qSr r .0k)rr r zget_scheme..csi|] }|qSr r r))rr rr,r-)schemevarsr%r"ZpythonZincludeZsiteZUNKNOWNplatlibpurelibscriptsdata)r0r1Zheadersr2r3)rr!rr _HOME_KEYS sysconfig get_pathsrgetrrrrpathjoinrr distutilsutilZ change_rootgetattrsetattr)r&rrr'r(rZ scheme_nameZ variablespathsr"Z python_xyr.keyvaluer )rrr get_scheme}sJ    rAcCs4tjdddkr(tjdddkr(dStdS)Ndarwinz/System/Library/z/usr/local/binr2)rplatformrr5r6r r r rget_bin_prefixs$rFcCs tdS)Nr1r5r6r r r r get_purelibsrHcCs tdS)Nr0rGr r r r get_platlibsrI)rr cCs"tj||dd}|d|dfS)N)r"r#)r/r1r0rG)rr>r r rget_prefixed_libssrJ)FNNFN)*Zdistutils.utilr:Zloggingrrr5typingZpip._internal.exceptionsrrZpip._internal.models.schemerrZpip._internal.utils.virtualenvrr"rr Z getLogger__name__loggersetZget_scheme_namesr r<rboolrstrrrr!r4Zget_config_varappendOptionalrArFrHrITuplerJr r r rsJ      M