U
    ™P^&  ã                   @   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 er¨dd
lmZmZmZmZ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
r   ej'Z%Y nX er`ej( )ej*d¡Z+ej( )e%d¡Z,ej( -e+¡sªej( )ej*d¡Z+ej( )e%d¡Z,nJej( )ej*d¡Z+ej( )e%d¡Z,ejdd… dkrªej*dd… dkrªdZ+ddd„Z.dS )z7Locations where we look for configs, install stuff, etcé    )Úabsolute_importN)Ú	sysconfig)ÚSCHEME_KEYS)Úappdirs)ÚWINDOWS)ÚMYPY_CHECK_RUNNING)Úrunning_under_virtualenv)ÚAnyÚUnionÚDictÚListÚOptionalÚ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-220asx0h/pip/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   ÚpurelibZpypyÚScriptsÚbiné   Údarwiné   z/System/Library/z/usr/local/binFc                 C   s†  ddl m} i }|r ddgi}ni }d| i}	|	 |¡ ||	ƒ}
|
 ¡  |
jddd}|d	k	s`t‚|rx|rxtd
 ||¡ƒ‚|r|rtd ||¡ƒ‚|p˜|j|_|s¤|rªd|_|p²|j|_|p¾|j	|_	|pÊ|j
|_
| ¡  tD ]}t|d| ƒ||< qÚd|
 d¡kr| t|j|jd¡ tƒ r‚tj tjddd tƒ ¡| ¡|d< |d	k	r‚tj tj |d ¡¡d }tj ||dd	… ¡|d< |S )z+
    Return a distutils install scheme
    r   )ÚDistributionÚscript_argsz--no-user-cfgÚnameÚinstallT)ÚcreateNzuser={} prefix={}zhome={} prefix={}Ú Úinstall_Úinstall_lib)r    ÚplatlibÚincludeÚsitezpython{}Úheadersé   )Údistutils.distr&   ÚupdateÚparse_config_filesÚget_command_objÚAssertionErrorr   Úuserr   ÚhomeÚrootÚfinalize_optionsr   ÚgetattrÚget_option_dictÚdictr-   r   r   r   r   r   r   Ú
splitdriver   )Ú	dist_namer8   r9   r:   Úisolatedr   r&   ÚschemeÚextra_dist_argsÚ	dist_argsÚdÚiÚkeyÚpath_no_driver   r   r   Údistutils_scheme[   sV    
	
û
ÿÿ
þrI   )FNNFN)/Ú__doc__Ú
__future__r   r   Úos.pathÚplatformr0   r   r   Ú	distutilsÚdistutils_sysconfigÚdistutils.command.installr   Zpip._internal.utilsr   Úpip._internal.utils.compatr   Úpip._internal.utils.typingr   Zpip._internal.utils.virtualenvr   Útypingr	   r
   r   r   r   Ú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ÚexistsrI   r   r   r   r   Ú<module>   sN   
	
(    ÿ