3
;p_L                 @   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j"dZ#dd Z$dd Z%ej&dZ'ej( j) dkr
e
j* Z'yej+ Z,W n e-k
r2   ej.Z,Y nX erej/j0ej1dZ2ej/j0e,dZ3ej/j4e2sej/j0ej1dZ2ej/j0e,dZ3nJej/j0ej1dZ2ej/j0e,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   8/tmp/pip-install-ofl94hr3/pip/pip/_internal/locations.pyget_major_minor_version"   s    r   c              C   sZ   t  rtjjtjd} n6ytjjtj d} W n tk
rL   tjd Y nX tj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"   purelibZpypyScriptsbin   darwin   z/System/Library/z/usr/local/binFc             C   s  ddl m} d| i}|r"dg|d< ||}|j  d}	|jddd	}	|	dk	sPttt|	}
|o`| sttd
j|||oz| stdj|||p|
j|
_|s|rd|
_	|p|
j	|
_	|p|
j
|
_
|p|
j|
_|
j  i }xtD ]}t|
d| ||< qW d|jdkr|jt|
j|
jd t rtjj|
j	dddjt | |d< |dk	rtjjtjj|d d }tj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dictr/   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_   sL    





rL   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
    r0   r#   r3   scriptsdata)r0   r#   r3   rM   rN   )rL   r   )rC   r:   r;   r<   rD   r   rI   r   r   r   
get_scheme   s    rO   )FNNFN)FNNFN)7__doc__
__future__r   r   os.pathplatformr2   r   r   	distutilsdistutils_sysconfigdistutils.command.installr   r   r9   Z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_libZgetusersitepackages	user_siteAttributeError	USER_SITEr   r   r   bin_pybin_userexistsrL   rO   r   r   r   r   <module>   sX   
	
(
A    