B
    Wíc\   ã               @   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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ZdZdd„ Zdd„ Zdd„ Z eƒ râej! "ej#d¡Z$n8yej! "e %¡ d¡Z$W n  e&k
r   e 'd¡ Y nX ej! (e$¡Z$e )d¡Z*e +¡  ,¡ dkrJe
 -¡ Z*ye .¡ Z/W n e0k
rr   ej1Z/Y nX edƒZ2erîej! "ej#d¡Z3ej! "e/d¡Z4ej! 5e3¡sÌej! "ej#d¡Z3ej! "e/d¡Z4dZ6ej! "e2d
¡Z7ej! "e7e6¡Z8njej! "ej#d¡Z3ej! "e/d¡Z4dZ6ej! "e2d¡Z7ej! "e7e6¡Z8ejdd… dkrXej#dd… d krXd!Z3d"d#„ e 9d
¡D ƒZ:ej! "ej#e6¡Z;ej! "e <d
¡e6¡Z=d'd%d&„Z>dS )(z7Locations where we look for configs, install stuff, etcé    )Úabsolute_importN)Ú	sysconfig)ÚSCHEME_KEYS)Úappdirs)ÚWINDOWSÚ
expanduser)ÚMYPY_CHECK_RUNNING)ÚAnyÚUnionÚDictÚListÚOptionalZpipz¹This file is placed here by pip to indicate the source was put
here by pip.

Once this package is successfully installed this source code will be
deleted (unless you remove this file).
zpip-delete-this-directory.txtc          	   C   s2   t j | t¡}t|dƒ}| t¡ W dQ R X dS )z?
    Write the pip delete marker file into this directory.
    ÚwN)ÚosÚpathÚjoinÚPIP_DELETE_MARKER_FILENAMEÚopenÚwriteÚDELETE_MARKER_MESSAGE)Z	directoryÚfilepathZ	marker_fp© r   ú6lib/python3.7/site-packages/pip/_internal/locations.pyÚwrite_delete_marker_file#   s    r   c               C   s*   t tdƒrdS tjttdtjƒkr&dS dS )zM
    Return True if we're running inside a virtualenv, False otherwise.

    Zreal_prefixTÚbase_prefixF)ÚhasattrÚsysÚprefixÚgetattrr   r   r   r   Úrunning_under_virtualenv-   s
    
r   c              C   sB   t j t j tj¡¡} t j | d¡}tƒ r:t j |¡r:dS dS dS )z?
    Return True if in a venv and no system site packages.
    zno-global-site-packages.txtTFN)	r   r   ÚdirnameÚabspathÚsiteÚ__file__r   r   Úisfile)Zsite_mod_dirZno_global_filer   r   r   Úvirtualenv_no_global;   s
    r%   Úsrcz=The folder you are executing pip from can no longer be found.ÚpurelibZpypyú~ZScriptsÚbinzpip.inizpip.confz.pipé   Údarwiné   z/System/Library/z/usr/local/binc             C   s   g | ]}t j |t¡‘qS r   )r   r   r   Úconfig_basename)Ú.0r   r   r   r   ú
<listcomp>‹   s   r/   Fc          	   C   sr  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
 ||¡ƒ‚|p€|j|_|rŽd|_|p–|j|_|p¢|j	|_	|p®|j
|_
| ¡  xtD ]}t|d| ƒ||< qÀW d|
 d¡krþ| t|j|jd¡ tƒ rntj tjdddtjd	d…  | ¡|d< |d	k	rntj tj |d ¡¡d }tj ||dd	… ¡|d< |S )z+
    Return a distutils install scheme
    r   )ÚDistributionZscript_argsz--no-user-cfgÚnameZinstallT)ZcreateNzuser={} prefix={}Ú Zinstall_Úinstall_lib)r'   ZplatlibZincluder"   Zpythoné   Zheadersé   )Zdistutils.distr0   ÚupdateZparse_config_filesZget_command_objÚAssertionErrorÚformatÚuserr   ÚhomeÚrootZfinalize_optionsr   r   Zget_option_dictÚdictr3   r   r   r   r   r   ÚversionÚ
splitdriver!   )Z	dist_namer9   r:   r;   Úisolatedr   r0   ZschemeZextra_dist_argsZ	dist_argsÚdÚiÚkeyZpath_no_driver   r   r   Údistutils_scheme“   sJ    

	

rC   )FNNFN)?Ú__doc__Z
__future__r   r   Úos.pathÚplatformr"   r   r   Z	distutilsZdistutils_sysconfigZdistutils.command.installr   Zpip._internal.utilsr   Zpip._internal.utils.compatr   r   Zpip._internal.utils.typingr   Útypingr	   r
   r   r   r   Zuser_cache_dirZUSER_CACHE_DIRr   r   r   r   r%   r   r   r   Z
src_prefixÚgetcwdÚOSErrorÚexitr!   Zget_pathZsite_packagesZpython_implementationÚlowerZget_python_libÚgetusersitepackagesÚ	user_siteÚAttributeErrorÚ	USER_SITEZuser_dirZbin_pyZbin_userÚexistsr-   Zlegacy_storage_dirZlegacy_config_fileZsite_config_dirsZsite_config_filesZvenv_config_fileZuser_config_dirZnew_config_filerC   r   r   r   r   Ú<module>   s|   
	

( 