U
    ~hbN                     @   s  d Z ddlmZ 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
 ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ erddlmZmZmZmZ ddlm Z! e"dZ#dd Z$dd Z%e&dZ'e( ) dkr
e
* Z'ze+ Z,W n e-k
r2   ej.Z,Y nX erej/0ej1dZ2ej/0e,dZ3ej/4e2sej/0ej1dZ2ej/0e,dZ3nJej/0ej1dZ2ej/0e,dZ3ejdd dkrej1dd dkrdZ2d!ddZ5d"dd Z6dS )#z7Locations where we look for configs, install stuff, etc    )absolute_importN)	sysconfig)SCHEME_KEYS)install)Scheme)appdirs)WINDOWS)MYPY_CHECK_RUNNINGcast)running_under_virtualenv)DictListOptionalUnion)Commandpipc                   C   s   dj tj S )ze
    Return the major-minor version of the current Python as a string, e.g.
    "3.7" or "3.10".
    z{}.{})formatsysversion_info r   r   ;/tmp/pip-unpacked-wheel-djcb_5rg/pip/_internal/locations.pyget_major_minor_version"   s    r   c                  C   sZ   t  rtjtjd} n6ztjt d} W n tk
rL   td Y nX tj	| S )Nsrcz=The folder you are executing pip from can no longer be found.)
r   ospathjoinr   prefixgetcwdOSErrorexitabspath)
src_prefixr   r   r   get_src_prefix+   s    
r"   purelibpypyScriptsbin   darwin   z/System/Library/z/usr/local/binFc                 C   s  ddl m} d| i}|r"dg|d< ||}|  d}	|jddd	}	|	dk	sPttt|	}
|rr|rrtd
|||r|rtd|||p|
j|
_|s|rd|
_	|p|
j	|
_	|p|
j
|
_
|p|
j|
_|
  i }tD ]}t|
d| ||< qd|dkr|t|
j|
jd t rtjtj	dddt | |d< |dk	rtjtj|d d }tj||dd |d< |S )z+
    Return a distutils install scheme
    r   )Distributionnamez--no-user-cfgscript_argsNr   T)createzuser={} prefix={}zhome={} prefix={} install_install_lib)r#   platlibincludesitezpython{}headers   )distutils.distr*   parse_config_filesget_command_objAssertionErrorr
   distutils_install_commandr   userr   homerootfinalize_optionsr   getattrget_option_dictupdatedictr0   r   r   r   r   r   r   
splitdriver    )	dist_namer;   r<   r=   isolatedr   r*   	dist_argsdobjischemekeypath_no_driver   r   r   distutils_scheme_   sV    




rM   c                 C   s8   t | |||||}t|d |d |d |d |d dS )a;  
    Get the "scheme" corresponding to the input parameters. The distutils
    documentation provides the context for the available schemes:
    https://docs.python.org/3/install/index.html#alternate-installation

    :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 and provides the base
        directory for the same
    :param root: root under which other directories are re-based
    :param isolated: equivalent to --no-user-cfg, i.e. do not consider
        ~/.pydistutils.cfg (posix) or ~/pydistutils.cfg (non-posix) for
        scheme paths
    :param prefix: indicates to use the "prefix" scheme and provides the
        base directory for the same
    r1   r#   r4   scriptsdata)r1   r#   r4   rN   rO   )rM   r   )rD   r;   r<   r=   rE   r   rJ   r   r   r   
get_scheme   s         rP   )FNNFN)FNNFN)7__doc__
__future__r   r   os.pathplatformr3   r   r   	distutilsdistutils_sysconfigdistutils.command.installr   r   r:   pip._internal.models.schemer   Zpip._internal.utilsr   pip._internal.utils.compatr   pip._internal.utils.typingr	   r
   pip._internal.utils.virtualenvr   typingr   r   r   r   distutils.cmdr   ZDistutilsCommanduser_cache_dirUSER_CACHE_DIRr   r"   get_pathsite_packagespython_implementationlowerget_python_libgetusersitepackages	user_siteAttributeError	USER_SITEr   r   r   bin_pybin_userexistsrM   rP   r   r   r   r   <module>   sd   
	
(         
B     