ó
Š]c           @  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 g Z d Z	 d Z
 d e	 f d e
 f 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	   bootstraps   40.6.2s   18.1t
   setuptoolst   pipc         C  s;   | d  k	 r | t j t _ n  d d  l } | j j |  ƒ S(   Niÿÿÿÿ(   t   Nonet   syst   patht   pip._internalt	   _internalt   main(   t   argst   additional_pathsR   (    (    s#   lib/python2.7/ensurepip/__init__.pyt   _run_pip   s    c           C  s   t  S(   sA   
    Returns a string specifying the bundled version of pip.
    (   t   _PIP_VERSION(    (    (    s#   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(   t   ost   environt
   startswitht   devnull(   t   kt   keys_to_remove(    (    s#   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#   lib/python2.7/ensurepip/__init__.pyR   6   s    
c         C  s°  | r | r t  d ƒ ‚ n  t ƒ  | r8 d t j d <n | sN d t j d <n  t j ƒ  } z;g  } x‘ t D]‰ \ } }	 d j | |	 ƒ }
 t j	 d d j |
 ƒ ƒ } t
 t j j | |
 ƒ d ƒ  } | j | ƒ Wd	 QX| j t j j | |
 ƒ ƒ qj Wd d
 d | g } |  r"| d |  g 7} n  | r8| d g 7} n  | rN| d g 7} n  | rl| d d | g 7} n  t | g  t D] } | d ^ qy| ƒ 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   installs   {}-{}-py2.py3-none-any.whlt	   ensurepips   _bundled/{}t   wbNs
   --no-indexs   --find-linkss   --roots	   --upgrades   --usert   -t   vi    t   ignore_errors(   t
   ValueErrorR   R   R   t   tempfilet   mkdtempt	   _PROJECTSt   formatt   pkgutilt   get_datat   openR   t   joint   writet   appendR   t   shutilt   rmtreet   True(   R   R   R   R   R   R   t   tmpdirR   t   projectR   t
   wheel_namet   whlt   fpR   t   p(    (    s#   lib/python2.7/ensurepip/__init__.pyR   E   s:    	! ,c         C  s¿   y d d l  } Wn t k
 r$ d SX| j t k r` d } t | j | j t ƒ d t j ƒd St ƒ  d d d g } |  r” | d d	 |  g 7} n  t	 | g  t
 t ƒ D] } | d
 ^ q§ ƒ 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$   i    (   R   t   ImportErrort   __version__R   t   printR*   R   t   stderrR   R   t   reversedR)   (   R   R   t   msgR   R9   (    (    s#   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    t   destR   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   t   FalseR   R3   t   SUPPRESSt
   parse_argsR   R   R   R   R   R   R   (   t   argvRK   t   parserR   (    (    s#   lib/python2.7/ensurepip/__init__.pyt   _main›   sf    		
					(   t
   __future__R    R   t   os.pathR+   R1   R   R'   t   __all__t   _SETUPTOOLS_VERSIONR   R)   R   R   R   R   RN   R3   R   R   RB   RS   (    (    (    s#   lib/python2.7/ensurepip/__init__.pyt   <module>   s,   	
				8