a lj @ s\ d dl Zd dlZd dlZd dlZd dlZd dlZd dlmZm Z d dl mZmZ d dl mZ ddlmZmZ eeZee ZeeddZedd d ZedddZedd dZedddZg dZ e!ddure "d d eeej#e ej#e eej#e edddZ$edddZ%edddZ&edddZ'eej(eef dddZ)dS )! N)InvalidSchemeCombinationUserInstallationInvalid)SCHEME_KEYSScheme)running_under_virtualenv )get_major_minor_versionis_osx_frameworkZget_preferred_scheme)returnc C s dt v ot ot S )a Check 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_SCHEMESr r r r F/usr/lib/python3.9/site-packages/pip/_internal/locations/_sysconfig.py _should_use_osx_framework_prefix s r c C sv t rt dS t rdS tjj dtj } | tv r6| S tjjtv rJtjjS tj d}|tv rb|S tjtv rrtjS dS )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 __prefixposix_prefix)_PREFERRED_SCHEME_APIr sysimplementationnameosr )Zimplementation_suffixedsuffixedr r r _infer_prefix8 s r c C sH t rt dS t rt sd} ntj d} | tv r6| S dtvrDt dS )z3Try to find a user scheme for the current platform.userZosx_framework_user_userZ posix_user)r r r r r r r r r r r _infer_userW s r c C s( t rt dS tj d} | tv r$| S dS )z,Try to find a home for the current platform.home_homeZ posix_home)r r r r r r r r _infer_homef s r! )Zinstalled_basebaseZinstalled_platbaseplatbaser exec_prefixuserbaseF) dist_namer r rootisolatedr r c sb |rrt dd r$r$t dd dur4t }n|r@t }nt }durZ|dkrZd} durv fddtD }n durfd dtD }ni }tj||d }t r|r|dt j } n|dt j } d t } tj | dd| |d<