o
    Ëý°jî  ã                   @   st  d dl Zd dlZd dlZd dlZd dlZd dlZd dlmZm	Z	 d dl
mZmZ d dlmZ ddlmZmZ e e¡Zee ¡ ƒZeeddƒZdefd	d
„Zdefdd„Zdefdd„Zdefdd„Zg d¢Z e !d¡durse  "d¡ 					d$dededej#e dej#e dedej#e defdd„Z$defdd„Z%defdd„Z&defd d!„Z'dedej(eef fd"d#„Z)dS )%é    N)ÚInvalidSchemeCombinationÚUserInstallationInvalid)ÚSCHEME_KEYSÚScheme)Úrunning_under_virtualenvé   )Úget_major_minor_versionÚis_osx_frameworkÚget_preferred_schemeÚreturnc                   C   s   dt v o
tƒ  o
tƒ 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   ú•/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/locations/_sysconfig.pyÚ _should_use_osx_framework_prefix   s
   ÿýr   c                  C   sv   t rt dƒS tƒ rdS tjj› dtj› �} | tv r| S tjjtv r%tjjS tj› d�}|tv r1|S tjtv r9tjS dS )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_APIr   ÚsysÚimplementationÚnameÚosr   )Úimplementation_suffixedÚsuffixedr   r   r   Ú_infer_prefix8   s   
r   c                  C   sH   t rt dƒS tƒ rtƒ sd} ntj› d�} | tv r| S dtvr"tƒ ‚dS )z3Try to find a user scheme for the current platform.ÚuserÚosx_framework_userÚ_userÚ
posix_user)r   r	   r   r   r   r   r   ©r   r   r   r   Ú_infer_userW   s   r"   c                  C   s(   t rt dƒS tj› d�} | tv r| S dS )z,Try to find a home for the current platform.ÚhomeÚ_homeÚ
posix_home)r   r   r   r   r!   r   r   r   Ú_infer_homef   s   r&   )Úinstalled_baseÚbaseÚinstalled_platbaseÚplatbaser   Úexec_prefixÚuserbaseFÚ	dist_namer   r#   ÚrootÚisolatedr   c                    s^  |r	ˆr	t ddƒ‚ˆ rˆrt ddƒ‚ˆ durtƒ }n	|r tƒ }ntƒ }ˆdur-|dkr-d}ˆ dur;‡ fdd„tD ƒ}nˆdurI‡fd	d„tD ƒ}ni }tj||d
�}tƒ rx|r_| dt	j
¡}	n| dt	j
¡}	dtƒ › �}
tj |	dd|
¡|d< n| s|d} t|d |d tj |d | ¡|d |d d�}|dur­tD ]}tj |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   r   c                    ó   i | ]}|ˆ “qS r   r   ©Ú.0Úk)r#   r   r   Ú
<dictcomp>¥   ó    zget_scheme.<locals>.<dictcomp>c                    r0   r   r   r1   )r   r   r   r4   §   r5   )ÚschemeÚvarsr,   r(   ÚpythonÚincludeÚsiteÚUNKNOWNÚplatlibÚpurelibÚscriptsÚdata)r<   r=   Úheadersr>   r?   )r   r&   r"   r   Ú
_HOME_KEYSÚ	sysconfigÚ	get_pathsr   Úgetr   r   r   r   ÚpathÚjoinr   r   Ú	distutilsÚutilÚchange_rootÚgetattrÚsetattr)r-   r   r#   r.   r/   r   Úscheme_nameÚ	variablesÚpathsr(   Ú	python_xyr6   ÚkeyÚvaluer   )r#   r   r   Ú
get_scheme}   sJ   

ûrR   c                   C   s4   t jd d… dkrt jd d… dkrdS t ¡ d S )Né   Údarwiné   z/System/Library/z/usr/local/binr>   )r   Úplatformr   rB   rC   r   r   r   r   Úget_bin_prefixÊ   s   $rW   c                   C   ó   t  ¡ d S )Nr=   ©rB   rC   r   r   r   r   Úget_purelibÑ   ó   rZ   c                   C   rX   )Nr<   rY   r   r   r   r   Úget_platlibÕ   r[   r\   c                 C   s"   t j| | dœd�}|d |d fS )N)r(   r*   )r7   r=   r<   rY   )r   rN   r   r   r   Úget_prefixed_libsÙ   s   r]   )FNNFN)*Údistutils.utilrG   Úloggingr   r   rB   ÚtypingÚpip._internal.exceptionsr   r   Úpip._internal.models.schemer   r   Úpip._internal.utils.virtualenvr   r(   r   r	   Ú	getLoggerÚ__name__ÚloggerÚsetÚget_scheme_namesr   rJ   r   Úboolr   Ústrr   r"   r&   rA   Úget_config_varÚappendÚOptionalrR   rW   rZ   r\   ÚTupler]   r   r   r   r   Ú<module>   sX    

úÿþýüûú
ùM 