o 7]h@stddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z m Z ddl mZddlmZmZeeZeeZeeddZdefd d Zdefd d Zdefd dZdefddZgdZ e!ddurse "d     d$dededej#edej#ededej#ede fddZ$defddZ%defddZ&defd d!Z'dedej(eeffd"d#Z)dS)%N)InvalidSchemeCombinationUserInstallationInvalid) SCHEME_KEYSScheme)running_under_virtualenv)get_major_minor_versionis_osx_frameworkget_preferred_schemereturncCsdtvo t o tS)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 rrD/usr/lib/python3/dist-packages/pip/_internal/locations/_sysconfig.py _should_use_osx_framework_prefixs rcCsvtrtdStr dStjjdtj}|tvr|Stjjtvr%tjjStjd}|tvr1|Stjtvr9tjSdS)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 )implementation_suffixedsuffixedrrr _infer_prefix8s   rcCsHtrtdStrtsd}ntjd}|tvr|Sdtvr"tdS)z3Try to find a user scheme for the current platform.userosx_framework_user_user posix_user)rr rrrr rrrrr _infer_userWs  r"cCs(trtdStjd}|tvr|SdS)z,Try to find a home for the current platform.home_home posix_home)rrrr r!rrr _infer_homefs  r&)installed_basebaseinstalled_platbaseplatbaser exec_prefixuserbaseF dist_namerr#rootisolatedrcs^|r r tddrrtdddurt}n |r t}nt}dur-|dkr-d}dur;fddtD}ndurIfd dtD}ni}tj||d }trx|r_|d t j } n|d t j } d t } t j | dd| |d<n|s|d}t|d|dt j |d||d|dd} |durtD]} tj|t| | } t| | | q| 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 rci|]}|qSrr.0k)r#rr zget_scheme..cr0rrr1)rrrr4r5)schemevarsr,r(pythonincludesiteUNKNOWNplatlibpurelibscriptsdata)r<r=headersr>r?)rr&r"r _HOME_KEYS sysconfig get_pathsrgetrrrrpathjoinrr distutilsutil change_rootgetattrsetattr)r-rr#r.r/r scheme_name variablespathsr( python_xyr6keyvaluer)r#rr get_scheme}sJ   rRcCs4tjdddkrtjdddkrdStdS)Ndarwinz/System/Library/z/usr/local/binr>)rplatformrrBrCrrrrget_bin_prefixs$ rWcC tdS)Nr=rBrCrrrr get_purelib rZcCrX)Nr<rYrrrr get_platlibr[r\cCs"tj||dd}|d|dfS)N)r(r*)r7r=r<rY)rrNrrrget_prefixed_libssr])FNNFN)*distutils.utilrGloggingrrrBtypingpip._internal.exceptionsrrpip._internal.models.schemerrpip._internal.utils.virtualenvrr(rr getLogger__name__loggersetget_scheme_namesr rJrboolrstrrr"r&rAget_config_varappendOptionalrRrWrZr\Tupler]rrrrsX      M