
 X:                 @   sR  d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l Z d d l	 m
 Z
 m Z m Z d d l Z d Z d Z d d   Z d	 d
   Z d d   Z d d   Z d d   Z e   re j j e j d  Z e j j e j d  Z nJ e   Z y e j j e j   d  Z Wn e k
 rMe j d  Yn Xe j j e j j e   Z e j j e  Z e
   Z  e j j! d  Z" e j# d k rqe j j e j d  Z$ e re j j e d  n d Z% e j j& e$  s/e j j e j d  Z$ e r&e j j e d  n d Z% n  e j j e" d  Z' e j j e' d  Z( e j j e' d  Z) n e j j e j d  Z$ e re j j e d  n d Z% e j j e" d  Z' e j j e' d  Z( e j j e' d  Z) e j# d d  d k r9e j d d  d  k r9d! Z$ e j j e" d"  Z) n  d# d d d$ d%  Z* d S)&z7Locations where we look for configs, install stuff, etc    N)installSCHEME_KEYS)get_python_libget_path_uid	user_sitezThis 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   s?   t  j j |  t  } t | d  } | j t  | j   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close)	directoryfilepath	marker_fp r   8/home/ubuntu/projects/ifolica/build/pip/pip/locations.pywrite_delete_marker_file   s    r   c               C   s9   t  t d  r d St j t t d t j  k r5 d Sd 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   sY   t  j j t  j j t j   }  t  j j |  d  } t   rU t  j j |  rU d Sd 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_global-   s    !r$   c              C   s;   t  j d k r t j   Sd d l }  |  j t j    j S)z8 Returns the effective username of the current process. win32r   N)	r   platformgetpassgetuserpwdgetpwuidr   geteuidpw_name)r)   r   r   r   __get_username7   s    
r-   c              C   s   t  j j t j   d t    }  t j d k r5 |  Sy t  j |   t	 |   Wn t
 k
 r d } y t |   } Wn t
 k
 r d } Yn X| t  j   k r d |  } t |  t d d  t j j |   n  Yn X|  S)z Returns a safe build_prefix zpip_build_%sr%   NzSThe temporary folder for building (%s) is either not owned by you, or is a symlink.z0pip will not work until the temporary folder is zAeither deleted or is a real directory owned by your user account.)r   r	   r
   tempfile
gettempdirr-   r   r&   mkdirr   OSErrorr   r+   printpip
exceptionsInstallationError)r	   file_uidmsgr   r   r   _get_build_prefix>   s*    
r8   buildsrcz=The folder you are executing pip from can no longer be found.~r%   Scriptsbinr3   zpip.inizpip.logz.pipzpip.conf   darwin   z/System/Library/z/usr/local/binzLibrary/Logs/pip.logFc       	      C   s8  d d l  m } i  } | i |  d 6 } | j   | j d d d } | pT | j | _ | pf | j | _ | px | j | _ | j   x% t D] } t	 | d |  | | <q Wt
   r4t j j t j d d	 d
 t j d d  |   | d <| d k	 r4t j j | t j j | d  d d   | d <q4n  | S)z+
    Return a distutils install scheme
    r   )Distributionnamer   createTinstall_includer   pythonN   headers   )distutils.distrA   parse_config_filesget_command_objuserhomerootfinalize_optionsr   r   r   r   r	   r
   r   r   versionr   )		dist_namerM   rN   rO   rA   schemedikeyr   r   r   distutils_scheme   s,    

		-rW   )+__doc__r   r   r   r.   distutils.command.installr   r   r'   Zpip.backwardcompatr   r   r   pip.exceptionsr3   r   r   r   r   r$   r-   r8   r	   r
   r   build_prefix
src_prefixgetcwdr1   exitr   realpathsite_packages
expanduseruser_dirr&   bin_pybin_userexistsdefault_storage_dirdefault_config_filedefault_log_filerW   r   r   r   r   <module>   sZ   	

			!$!2