î
½1kd:  ã               @   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_sitez¹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   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   ú</var/www/pythonscrapper/code/venv/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