
<^Yc           @@  s  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 m	 Z	 d d l
 m Z d d l m Z d d l m Z d d l m Z m Z m Z m Z m Z d d	 l m Z d d
 l m Z m Z d d l m Z m Z d d l m Z m  Z  m! Z! m" Z" m# Z# d d l$ m% Z% m& Z& m' Z' d d l( m) Z) d d l* m+ Z+ d g Z, e j- e.  Z/ d e0 f d     YZ1 d e1 f d     YZ2 d S(   s(   Base Command class, and related routinesi    (   t   absolute_importN(   t
   cmdoptions(   t   PackageFinder(   t   running_under_virtualenv(   t
   PipSession(   t
   BadCommandt   InstallationErrort   UninstallationErrort   CommandErrort   PreviousBuildDirError(   t   logging_dictConfig(   t   ConfigOptionParsert   UpdatingDefaultsHelpFormatter(   t   InstallRequirementt   parse_requirements(   t   SUCCESSt   ERRORt   UNKNOWN_ERRORt   VIRTUALENV_NOT_FOUNDt   PREVIOUS_BUILD_DIR_ERROR(   t   deprecationt   get_progt   normalize_path(   t   IndentingFormatter(   t   pip_version_checkt   Commandc           B@  sM   e  Z d Z d Z e Z d Z e d  Z d d d  Z	 d   Z
 d   Z RS(   s   ext://sys.stdouts   ext://sys.stderrc         C@  s   i |  j  d 6d t   |  j f d 6t   d 6t d 6|  j d 6|  j d 6| d 6} t |   |  _ d	 |  j j   } t	 j
 |  j |  |  _ t j t j |  j  } |  j j |  d  S(
   Nt   usages   %s %st   progt	   formattert   add_help_optiont   namet   descriptiont   isolateds
   %s Options(   R   R   R   R   t   Falset   __doc__R   t   parsert
   capitalizet   optparset   OptionGroupt   cmd_optsR   t   make_option_groupt   general_groupt   add_option_group(   t   selfR    t	   parser_kwt   optgroup_namet   gen_opts(    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyt   __init__)   s    




c         C@  s   t  d | j r- t t j j | j d   n d  d | d  k	 rE | n | j d | j  } | j	 rr | j	 | _
 n  | j r | j | _	 n  | j s | r | d  k	 r | n | j | _ n  | j r i | j d 6| j d 6| _ n  | j | j _ | S(   Nt   cachet   httpt   retriest   insecure_hostst   https(   R   t	   cache_dirR   t   ost   patht   joint   NoneR2   t   trusted_hostst   certt   verifyt   client_certt   timeoutt   proxyt   proxiest   no_inputt   autht	   prompting(   R+   t   optionsR2   R>   t   session(    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyt   _build_sessionA   s     -		!	
c         C@  s   |  j  j |  S(   N(   R#   t
   parse_args(   R+   t   args(    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyRG   e   s    c         @  s  |  j  |  \ } } | j rW | j d k r6 d   n  | j d k rN d   qo d   n | j ri d   n d     } | j r d } n  t i d d 6t d	 6i i d
 d 6t j d 6d 6d 6i i t d 6d d 6d 6d 6i i   d 6d d 6|  j	 d d 6d g d 6d d 6d 6i d d 6d d 6|  j	 d d 6d d 6d 6i d d 6d d 6| j pTd d 6t
 d 6d d 6d 6d 6i | d 6t t d  d d | j rd n d  g   d 6d  6t   f d!   d" d# d$ d% g D  d& 6 t j d  d7 k r t j d( t j  n  | j rd) t j d* <n  | j r>d+ j | j  t j d, <n  | j rpt   spt j d-  t j t  qpn  z-y) |  j  | |  } t! | t"  r| SWn t# k
 r} t j t$ |   t j% d. d/ t
 t& St' t( t) f k
 r} t j t$ |   t j% d. d/ t
 t* St+ k
 rP} t j d0 |  t j% d. d/ t
 t* St, k
 rt j d1  t j% d. d/ t
 t* St j d2 d/ t
 t- SXWd  | j. rt/ | d3 t  r|  j0 | d4 d d5 t1 d6 | j2   } t3 |  Wd  QXn  Xt4 S(8   Ni   t   WARNINGi   R   t   CRITICALt   DEBUGt   INFOt   versiont   disable_existing_loggerss    pip.utils.logging.MaxLevelFilters   ()t   levelt   exclude_warningst   filterss   %(message)st   formatt   indentt
   formatterss(   pip.utils.logging.ColorizedStreamHandlert   classi    t   streamR   t   consolet   console_errorss+   pip.utils.logging.BetterRotatingFileHandlers	   /dev/nullt   filenamet   delayt   user_logt   handlerst   rootc         3@  s4   |  ]* } | i   d k r! d n d d 6f Vq d S(   RL   R   RI   RK   RO   N(   s   INFOs   ERROR(    (   t   .0R   (   RO   (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pys	   <genexpr>   s   
s   pip._vendort   distlibt   requestst   urllib3t   loggersi   s   Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6t   1t   PIP_NO_INPUTt    t   PIP_EXISTS_ACTIONs2   Could not find an activated virtualenv (required).s   Exception information:t   exc_infos	   ERROR: %ss   Operation cancelled by users
   Exception:t   no_indexR2   R>   i   (   i   i   (5   RG   t   quiett   verboset   logR
   R!   t   loggingRI   R   t   log_streamst   Truet   listt   filterR9   t   dictt   syst   version_infot   warningst   warnR   t   Python26DeprecationWarningRA   R6   t   environt   exists_actionR8   t   require_venvR   t   loggert   criticalt   exitR   t   runt
   isinstancet   intR	   t   strt   debugR   R   R   R   R   R   t   KeyboardInterruptR   t   disable_pip_version_checkt   getattrRF   t   minR>   R   R   (   R+   RH   RD   t
   root_levelt   statust   excRE   (    (   RO   s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyt   maini   s    								
	#
				 	
N(   s   ext://sys.stdouts   ext://sys.stderr(   t   __name__t
   __module__R9   R   R   R!   t   hiddenRm   R/   RF   RG   R   (    (    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyR   #   s   $	t   RequirementCommandc           B@  s,   e  Z e d     Z d d d d d  Z RS(   c         C@  s  xS | j  D]H } x? t | d t d | d | d | d | D] } |  j |  q; Wq
 Wx6 | D]. } |  j t j | d d | j d |  q] Wx? | j D]4 } |  j t j	 | d | j
 d | j d |  q Wt }	 xS | j D]H } x? t | d | d | d | d | D] } t }	 |  j |  qWq W| j |  _ | pK| j pK|	 si | d 6}
 | j rd	 t |
 d
 d j | j  } n
 d |
 } t j |  n  d S(   s?   
        Marshal cmd line args into a requirement set.
        t
   constraintt   finderRD   RE   t   wheel_cacheR    t   default_vcsR   s^   You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?)t   linksRe   sL   You must give at least one requirement to %(name)s (see "pip help %(name)s")N(   t   constraintsR   Rn   t   add_requirementR   t	   from_lineR9   t   isolated_modet	   editablest   from_editableR   R!   t   requirementst   require_hashest
   find_linksRq   R8   Rz   t   warning(   t   requirement_setRH   RD   R   RE   R   R   RY   t   reqt   found_req_in_filet   optst   msg(    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyt   populate_requirement_set  sF    			"c         C@  s   | j  g | j } | j r> t j d d j |   g  } n  t d | j d | j d | d | j	 d | j
 d | j d	 | d
 | d | d | d |  S(   sR   
        Create a package finder appropriate to this requirement command.
        s   Ignoring indexes: %st   ,R   t   format_controlt
   index_urlsR:   t   allow_all_prereleasest   process_dependency_linksRE   t   platformt   versionst   abit   implementation(   t	   index_urlt   extra_index_urlsRh   Rz   R   R8   R   R   R   R:   t   preR   (   R+   RD   RE   R   t   python_versionsR   R   R   (    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyt   _build_package_finder:  s     							N(   R   R   t   staticmethodR   R9   R   (    (    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyR     s   8(3   R"   t
   __future__R    Rl   R6   Rr   R%   Rt   t   pipR   t	   pip.indexR   t   pip.locationsR   t   pip.downloadR   t   pip.exceptionsR   R   R   R   R	   t
   pip.compatR
   t   pip.baseparserR   R   t   pip.reqR   R   t   pip.status_codesR   R   R   R   R   t	   pip.utilsR   R   R   t   pip.utils.loggingR   t   pip.utils.outdatedR   t   __all__t	   getLoggerR   Rz   t   objectR   R   (    (    (    s,   /tmp/pip-build-YOdFBd/pip/pip/basecommand.pyt   <module>   s,   ((	