U
    +|jG  ã                   @   sì   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 e e¡Zee ¡ ƒZdd„ Zd	d
„ Zdd„ ZddddddgZe d¡dk	r¾e d¡ ddd„Zdd„ Zdd„ Zdd„ Z dd„ Z!dS ) é    N)ÚInvalidSchemeCombinationÚUserInstallationInvalid)ÚSCHEME_KEYSÚScheme)Úrunning_under_virtualenvé   )Úget_major_minor_versionc                  C   s`   t jj› dtj› �} | tkr | S t jjtkr4t jjS tj› d�}|tkrL|S tjtkr\tjS dS )a�  Try to find a prefix scheme for the current platform.

    This tries:

    * 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``.
    Ú_Ú_prefixÚposix_prefix)ÚsysÚimplementationÚnameÚosÚ_AVAILABLE_SCHEMES)Úimplementation_suffixedÚsuffixed© r   újC:\Users\snmko\Desktop\web_content\django_cbt\venv\Lib\site-packages\pip/_internal/locations/_sysconfig.pyÚ_infer_prefix   s    
r   c                  C   s*   t j› d�} | tkr| S dtkr&tƒ ‚dS )z3Try to find a user scheme for the current platform.Ú_userÚ
posix_user)r   r   r   r   ©r   r   r   r   Ú_infer_user6   s    r   c                  C   s   t j› d�} | tkr| S dS )z,Try to find a home for the current platform.Ú_homeÚ
posix_home)r   r   r   r   r   r   r   Ú_infer_homeA   s    r   Úinstalled_baseÚbaseÚinstalled_platbaseÚplatbaseÚprefixÚexec_prefixÚuserbaseFc                    sN  |rˆrt ddƒ‚ˆ r$ˆr$t ddƒ‚ˆ dk	r4tƒ }n|r@tƒ }ntƒ }ˆ dk	rb‡ fdd„tD ƒ}n ˆdk	r~‡fdd„tD ƒ}ni }tj||d�}tƒ rÜ|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k	�rJt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--homeNc                    s   i | ]
}|ˆ “qS r   r   ©Ú.0Úk)Úhomer   r   Ú
<dictcomp>z   s      zget_scheme.<locals>.<dictcomp>c                    s   i | ]
}|ˆ “qS r   r   r$   )r!   r   r   r(   |   s      )ÚschemeÚvarsr#   r   ÚpythonÚincludeÚsiteÚUNKNOWNÚplatlibÚpurelibÚscriptsÚdata)r/   r0   Úheadersr1   r2   )r   r   r   r   Ú
_HOME_KEYSÚ	sysconfigÚ	get_pathsr   Úgetr   r!   r   r   ÚpathÚjoinr   r   Ú	distutilsÚutilÚchange_rootÚgetattrÚsetattr)Ú	dist_nameÚuserr'   ÚrootÚisolatedr!   Úscheme_nameÚ	variablesÚpathsr   Ú	python_xyr)   ÚkeyÚvaluer   )r'   r!   r   Ú
get_schemeW   sF    

û
rI   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/binr1   )r   Úplatformr!   r5   r6   r   r   r   r   Úget_bin_prefixŸ   s    $rN   c                   C   s   t  ¡ d S )Nr0   ©r5   r6   r   r   r   r   Úget_purelib§   s    rP   c                   C   s   t  ¡ d S )Nr/   rO   r   r   r   r   Úget_platlib¬   s    rQ   c                 C   s"   t j| | dœd�}|d |d fS )N)r   r    )r*   r0   r/   rO   )r!   rE   r   r   r   Úget_prefixed_libs±   s    rR   )FNNFN)"Údistutils.utilr:   Úloggingr   r   r5   ÚtypingÚpip._internal.exceptionsr   r   Úpip._internal.models.schemer   r   Úpip._internal.utils.virtualenvr   r   r   Ú	getLoggerÚ__name__ÚloggerÚsetÚget_scheme_namesr   r   r   r   r4   Úget_config_varÚappendrI   rN   rP   rQ   rR   r   r   r   r   Ú<module>   sB   
ú
     ú
H