a
    <BìjW  ã                   @  s(  d Z ddlmZ zedƒ ¡  W n eefy6   Y n0 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 ddlmZ e e¡Zd"ddœdddddddddœdd„Zd#ddddddddœdd„Zddœdd„Z ddœdd„Z!ddœd d!„Z"dS )$z7Locations where we look for configs, install stuff, etcé    )ÚannotationsZ_distutils_hackN)ÚCommand)ÚSCHEME_KEYS)Úinstall©Úget_python_lib)ÚScheme)ÚWINDOWS)Úrunning_under_virtualenvé   )Úget_major_minor_versionF)Úignore_config_filesÚstrÚboolz
str | Nonezdict[str, str])Ú	dist_nameÚuserÚhomeÚrootÚisolatedÚprefixr   Úreturnc             
   C  sæ  ddl m} d| i}|r"dg|d< ||ƒ}	|srz|	 ¡  W n6 typ   |	 ¡ }
t dd dd	„ |
D ƒ¡¡ Y n0 d
}|	jddd�}|d
us�J ‚|}|r°|r°J d|› d|› �ƒ‚|rÌ|rÌJ d|› d|› �ƒ‚|pÔ|j	|_	|sà|ræd|_
|pî|j
|_
|pú|j|_|�p|j|_| ¡  i }tD ]}t|d| ƒ||< �qd|	 d¡v �rZ| |j|jdœ¡ tƒ �râ|�rn|}n|�r||j}n|j
}tj |dddtƒ › �| ¡|d< |d
u�râtj tj |d ¡¡d }t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 |¡V  qd S )N)ÚosÚpathÚbasename)Ú.0Úp© r   úa/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pip/_internal/locations/_distutils.pyÚ	<genexpr>?   ó    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_objr   r   r   r   Úfinalize_optionsr   ÚgetattrÚget_option_dictÚupdater&   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$   sb    
þ

û
rD   r   )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,   rE   rF   )rD   r   )r   r   r   r   r   r   rA   r   r   r    Ú
get_schemet   s    ûrG   )r   c                  C  sr   t j tj¡} tr>t j | d¡}t j |¡s:t j | d¡}|S tjd d… dkrd| d d… dkrddS t j | d¡S )NZScriptsÚbiné   Údarwiné   z/System/Library/z/usr/local/bin)	r   r   ÚnormpathÚsysr   r	   r3   ÚexistsÚplatform)r   Úbin_pyr   r   r    Úget_bin_prefix—   s    "rQ   c                   C  s
   t dd�S )NF©Úplat_specificr   r   r   r   r    Úget_purelib¨   s    rT   c                   C  s
   t dd�S )NTrR   r   r   r   r   r    Úget_platlib¬   s    rU   )FNNFN)FNNFN)#Ú__doc__Ú
__future__r   Ú
__import__Zremove_shimÚImportErrorÚAttributeErrorÚloggingr   rM   Údistutils.cmdr   ZDistutilsCommandÚdistutils.command.installr   r   Údistutils_install_commandÚdistutils.sysconfigr   Úpip._internal.models.schemer   Úpip._internal.utils.compatr	   Úpip._internal.utils.virtualenvr
   Úbaser   Ú	getLoggerÚ__name__r1   rD   rG   rQ   rT   rU   r   r   r   r    Ú<module>   sD   
     úø R     ú#