ó
čžbc           @  ső   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 Z d d g Z	 d   Z
 d d g Z d d  Z d	   Z d
   Z d e e e e d d  Z d e e e e d d  Z d d  Z d d  Z d S(   i˙˙˙˙(   t   print_functionNt   versiont	   bootstrapc           C  s$   t  r  t d  t j d  n  d  S(   NsĽ  ensurepip is disabled in Debian/Ubuntu for the system python.

Python modules For the system python are usually handled by dpkg and apt-get.

    apt-get install python-<module name>

Install the python-pip package to use pip itself.  Using pip together
with the system python might have unexpected results for any system installed
module, so use it on your own risk, or make sure to only use it in virtual
environments.
i   (   t   Truet   printt   syst   exit(    (    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyt    _ensurepip_is_disabled_in_debian   s    t
   setuptoolst   pipc         C  s;   | d  k	 r | t j t _ n  d d  l } | j j |   S(   Ni˙˙˙˙(   t   NoneR   t   patht   pip._internalt	   _internalt   main(   t   argst   additional_pathsR	   (    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyt   _run_pip%   s    c          C  sm   t    d }  t j d |   } t |  d k rS t j j | d  j d  d St d |  |  f   d S(   sA   
    Returns a string specifying the bundled version of pip.
    R	   s!   /usr/share/python-wheels/%s-*.whli   i    t   -sb   missing dependency wheel %s. Installation of the python-%s-whl package is needed to use ensurepip.N(   R   t   globt   lent   osR   t   basenamet   splitt   RuntimeError(   t   whl_namet   wheel_names(    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyR   /   s    !c          C  sZ   g  t  j D] }  |  j d  r
 |  ^ q
 } x | D] }  t  j |  =q2 Wt  j t  j d <d  S(   Nt   PIP_t   PIP_CONFIG_FILE(   R   t   environt
   startswitht   devnull(   t   kt   keys_to_remove(    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyt#   _disable_pip_configuration_settings;   s    +i    c         C  s/   t  d |  d | d | d | d | d |  d S(   s­   
    Bootstrap pip into the current Python installation (or the given root
    directory).

    Note that calling this function will alter both sys.path and os.environ.
    t   roott   upgradet   usert
   altinstallt   default_pipt	   verbosityN(   t
   _bootstrap(   R#   R$   R%   R&   R'   R(   (    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyR   G   s    
c      	   C  sJ  t    | r" | r" t d   n  t   | r? d t j d <n | sU d t j d <n  d   } g  } xI t t  D]; } t j d |  }	 t |	  d k rq | j	 |  qq qq W| rű t
 d d	 j | g  d	 j g  | D] }
 d
 |
 ^ qŘ  f   n  t j   } x t D]} } yJ t d |  4 } g  | j   D] } | d  j   d ^ q7} Wd QXWn t k
 rwg  } n X| | | t j  qWz  g  } | t | |  d d d | g } |  rÓ| d |  g 7} n  | ré| d g 7} n  | r˙| d g 7} n  | r| d d | g 7} n  t | t |  SWd t j | d t Xd S(   sÎ   
    Bootstrap pip into the current Python installation (or the given root
    directory). Returns pip command status code.

    Note that calling this function will alter both sys.path and os.environ.
    s.   Cannot use altinstall and default_pip togetherR&   t   ENSUREPIP_OPTIONSt   installc   
      S  s  x|  D]ý } t  j  d j |   } t |  d k rP t d | | f   n  t |  d k sn t |   t j j | d  } t j j d |  } t	 | d   } | j
   } Wd  QXt j j | |  }	 t	 |	 d   } | j |  Wd  QX| j |	  q Wd  S(   Ns!   /usr/share/python-wheels/{}-*.whli    sb   missing dependency wheel %s. Installation of the python-%s-whl package is needed to use ensurepip.i   s   /usr/share/python-wheelst   rbt   wb(   R   t   formatR   R   t   AssertionErrorR   R   R   t   joint   opent   readt   writet   append(
   t   wheelst   destdirt   pathst   projectR   t
   wheel_nameR   t   fpt   whlt   dest(    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyt   copy_wheelsv   s    s!   /usr/share/python-wheels/%s-*.whli   sR   missing wheel(s) %s. Installation of the %s package(s) is needed to use ensurepip.s   , s   python-%s-whls(   /usr/share/python-wheels/%s.dependenciesi˙˙˙˙i    Ns
   --no-indexs   --find-linkss   --roots	   --upgrades   --userR   t   vt   ignore_errors(   R   t
   ValueErrorR"   R   R   t   reversedt	   _PROJECTSR   R   R4   R   R0   t   tempfilet   mkdtempR1   t	   readlinesR   t   IOErrorR   R   R   t   shutilt   rmtreeR   (   R#   R$   R%   R&   R'   R(   R=   t   missingR8   R   t   mt   tmpdirR:   t   linet   dependenciesR   R   (    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyR)   V   sP    		07
c         C  sŽ   y d d l  } Wn t k
 r$ d SXt rf | j t k rf d } t | j | j t  d t j d St	   d d d g } |  r | d d	 |  g 7} n  t
 | t t   S(
   s~   Helper to support a clean default uninstall process on Windows

    Note that calling this function may alter os.environ.
    i˙˙˙˙NsO   ensurepip will only uninstall a matching version ({!r} installed, {!r} bundled)t   filet	   uninstalls   -ys   --disable-pip-version-checkR   R>   (   R	   t   ImportErrort   Falset   __version__t   _PIP_VERSIONR   R.   R   t   stderrR"   R   RA   RB   (   R(   R	   t   msgR   (    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyt   _uninstall_helperą   s    "c         C  s}  d d  l  } | j d d  } | j d d d d d j t    d d	 | j d
 d d d d d d d d d | j d d d d d t d d | j d d d d t d d | j d d d  d d | j d d d d t d d | j d d d d t d d d | j | j d d d d d d d  | j	 |   } t
 d! | j d" | j d# | j d | j d$ | j d | j  S(%   Ni˙˙˙˙t   progs   python -m ensurepips	   --versiont   actionR   s   pip {}t   helps9   Show the version of pip that is bundled with this Python.s   -vs	   --verboset   countt   defaulti    R<   R(   sD   Give more output. Option is additive, and can be used up to 3 times.s   -Us	   --upgradet
   store_trues8   Upgrade pip and dependencies, even if already installed.s   --users   Install using the user scheme.s   --roots=   Install everything relative to this alternate root directory.s   --altinstallso   Make an alternate install, installing only the X.Y versioned scripts (Default: pipX, pipX.Y, easy_install-X.Y).s   --default-pipR'   s   --no-default-pipt   store_falsesL   Make a non default install, installing only the X and X.Y versioned scripts.R#   R$   R%   R&   (   t   argparset   ArgumentParsert   add_argumentR.   R   RQ   R
   R   t   SUPPRESSt
   parse_argsR)   R#   R$   R%   R(   R&   R'   (   t   argvR^   t   parserR   (    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyt   _mainÎ   sf    		
					(   t
   __future__R    R   R   t   os.patht   pkgutilRG   R   RC   t   __all__R   RB   R
   R   R   R"   RQ   R   R   R)   RV   Re   (    (    (    s(   /usr/lib/python2.7/ensurepip/__init__.pyt   <module>   s,   		
				Y