3
Ug                 @   s@  d 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mZmZmZmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ejeZdddee eee ee eeef dddZ!d ee ee ee e ee edddZ"edddZ#edddZ$edddZ%eeeef dddZ&dS )!z7Locations where we look for configs, install stuff, etc    N)Command)SCHEME_KEYS)install)get_python_lib)DictListOptionalTupleUnioncast)Scheme)WINDOWS)running_under_virtualenv   )get_major_minor_versionF)ignore_config_files)	dist_nameuserhomerootisolatedprefixr   returnc            C   s  ddl m} d| i}|r"dg|d< ||}	|sty|	j  W n8 tk
rr   |	j }
tjddjdd	 |
D  Y nX d
}|	jddd}|d
k	st	t
t|}|o| st	d| d| |o| st	d| d| |p|j|_|s|rd|_|p|j|_|p|j|_|p|j|_|j  i }x tD ]}t|d| ||< q,W d|	jdkrn|jt|j|jd t r|r|}n|r|j}n|j}tjj|ddd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_argsz6Ignore distutils configs in %s due to encoding errors.z, c             s   s   | ]}t jj|V  qd S )N)ospathbasename).0p r!   F/tmp/pip-unpacked-wheel-0ht26j5g/pip/_internal/locations/_distutils.py	<genexpr>4   s    z#distutils_scheme.<locals>.<genexpr>Nr   T)createzuser=z prefix=zhome= install_install_lib)purelibplatlibincludesitepythonheadersr   )distutils.distr   parse_config_filesUnicodeDecodeErrorfind_config_filesloggerwarningjoinget_command_objAssertionErrorr   distutils_install_commandr   r   r   r   finalize_optionsr   getattrget_option_dictupdatedictr'   r   install_userbaser   r   r   
splitdriveabspath)r   r   r   r   r   r   r   r   	dist_argsdpathsobjischemekeypath_no_driver!   r!   r"   distutils_scheme   s^    





rH   )r   r   r   r   r   r   r   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
    r)   r(   r-   scriptsdata)r)   r(   r-   rI   rJ   )rH   r   )r   r   r   r   r   r   rE   r!   r!   r"   
get_schemei   s    rK   )r   c              C   sr   t jjtj} tr>t jj| d}t jj|s:t jj| d}|S tjd d dkrd| d d dkrddS t jj| dS )NScriptsbin   darwin   z/System/Library/z/usr/local/bin)	r   r   normpathsysr   r   r4   existsplatform)r   bin_pyr!   r!   r"   get_bin_prefix   s    "rV   c               C   s
   t ddS )NF)plat_specific)r   r!   r!   r!   r"   get_purelib   s    rX   c               C   s
   t ddS )NT)rW   )r   r!   r!   r!   r"   get_platlib   s    rY   )r   r   c             C   s   t d| dt d| dfS )NF)rW   r   T)r   )r   r!   r!   r"   get_prefixed_libs   s    
rZ   )FNNFN)FNNFN)'__doc__loggingr   rR   distutils.cmdr   ZDistutilsCommanddistutils.command.installr   r   r7   distutils.sysconfigr   typingr   r   r   r	   r
   r   pip._internal.models.schemer   pip._internal.utils.compatr   pip._internal.utils.virtualenvr   baser   	getLogger__name__r2   strboolrH   rK   rV   rX   rY   rZ   r!   r!   r!   r"   <module>   s<    
    J    