B
    ãUvg£  ã               @   sp  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 e d¡Zd	Zd
Zdd„ Zdd„ Zdd„ Zeƒ r¶ej ejd¡Zn6y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re
 %¡ Z"ye &¡ Z'W n e(k
rD   ej)Z'Y nX edƒZ*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,dZ.ej e*d¡Z/ej e/e.¡Z0njej ejd¡Z+ej e'd¡Z,dZ.ej e*d¡Z/ej e/e.¡Z0ejdd… dkr*ejdd… dkr*dZ+d d!„ e 1d¡D ƒZ2ej eje.¡Z3ej e 4d¡e.¡Z5d%d#d$„Z6dS )&z7Locations where we look for configs, install stuff, etcé    )Úabsolute_importN)Ú	sysconfig)ÚSCHEME_KEYS)Úappdirs)ÚWINDOWSÚ
expanduserÚ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)Ú	directoryÚfilepathÚ	marker_fp© r   ú8/tmp/pip-install-r_9ig3yj/pip/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.

    Úreal_prefixTÚbase_prefixF)ÚhasattrÚsysÚprefixÚgetattrr   r   r   r   Úrunning_under_virtualenv'   s
    
r   c              C   s>   t j t j tj¡¡} t j | d¡}tƒ r:t j |¡r:dS dS )z?
    Return True if in a venv and no system site packages.
    zno-global-site-packages.txtTN)	r
   r   ÚdirnameÚabspathÚsiteÚ__file__r   r   Úisfile)Úsite_mod_dirÚno_global_filer   r   r   Úvirtualenv_no_global4   s    r%   Úsrcz=The folder you are executing pip from can no longer be found.ÚpurelibZpypyú~Ú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   r0   Fc          	   C   sf  ddl m} i }|r ddgi}ni }d| i}	|	 |¡ ||	ƒ}
|
 ¡  |
jddd}|rl|rltd	 ||¡ƒ‚|pt|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ƒ rbtj tjdddtjdd…  | ¡|d< |dk	rbt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)Úcreatezuser={} prefix={}Ú Úinstall_Úinstall_lib)r'   ÚplatlibÚincluder    ÚpythonNé   Úheadersé   )Údistutils.distr1   ÚupdateÚparse_config_filesÚget_command_objÚAssertionErrorÚformatÚuserr   ÚhomeÚrootÚfinalize_optionsr   r   Úget_option_dictÚdictr8   r   r
   r   r   r   ÚversionÚ
splitdriver   )Ú	dist_namerE   rF   rG   Úisolatedr   r1   ÚschemeÚextra_dist_argsÚ	dist_argsÚdÚiÚkeyÚpath_no_driver   r   r   Údistutils_schemeˆ   sH    



rV   )FNNFN)7Ú__doc__Ú
__future__r   r
   Úos.pathÚplatformr    r   r   Ú	distutilsÚdistutils_sysconfigÚdistutils.command.installr   Úpip._internal.utilsr   Úpip._internal.utils.compatr   r   Úuser_cache_dirÚUSER_CACHE_DIRr   r   r   r   r%   r   r   r   Ú
src_prefixÚgetcwdÚOSErrorÚexitr   Úget_pathÚsite_packagesÚpython_implementationÚlowerÚget_python_libÚgetusersitepackagesÚ	user_siteÚAttributeErrorÚ	USER_SITEÚuser_dirÚbin_pyÚbin_userÚexistsr.   Úlegacy_storage_dirÚlegacy_config_fileÚsite_config_dirsÚsite_config_filesÚvenv_config_fileÚuser_config_dirÚnew_config_filerV   r   r   r   r   Ú<module>   sv   
		
( 