a
    e0h                     @   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 ddlmZmZm Z m!Z! e"dZ#dd Z$dd Z%ej&dd dkpe' ( dkZ)dZ*e)re
+ Z*n
e,dZ*ze- Z.W n e/yN   ej0Z.Y n0 erej12ej3dZ4ej12e.dZ5ej16e4sej12ej3dZ4ej12e.dZ5nJej12ej3dZ4ej12e.dZ5ejdd dkrej3dd dkrdZ4d#dd Z7d$d!d"Z8d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)Command)DictListOptionalUnion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   E/var/www/auris/lib/python3.9/site-packages/pip/_internal/locations.pyget_major_minor_version!   s    r   c                  C   sX   t  rtjtjd} n4ztjt d} W n tyJ   td Y n0 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"      )r#      pypypurelibZ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usPJ tt|	}
|rr|rrJ d
|||r|rJ d|||p|
j|
_|s|rd|
_|p|
j|
_|p|
j	|
_	|p|
j
|
_
|
  i }tD ]}t|
d| ||< qd|dv r|t|
j|
jd t rtj|
jdddt | |d< |du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_objr
   distutils_install_commandr   userr   homerootfinalize_optionsr   getattrget_option_dictupdatedictr1   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_schemed   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
    r2   r&   r5   scriptsdata)r2   r&   r5   rN   rO   )rM   r   )rD   r;   r<   r=   rE   r   rJ   r   r   r   
get_scheme   s    rP   )FNNFN)FNNFN)9__doc__
__future__r   r   os.pathplatformr4   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   distutils.cmdr   ZDistutilsCommandtypingr   r   r   r   user_cache_dirUSER_CACHE_DIRr   r"   r   python_implementationlowercan_not_depend_on_purelibsite_packagesget_python_libget_pathgetusersitepackages	user_siteAttributeError	USER_SITEr   r   r   bin_pybin_userexistsrM   rP   r   r   r   r   <module>   sd   
	

( 
B     