
@^Yc           @  s9  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	 m
 Z
 d d l m Z d d l m Z d d l m Z d d l m Z d	   Z d
   Z e d  Z d   Z d   Z d e f d     YZ d e f d     YZ d f  d     YZ e j j j d  Z d   Z  d S(   s   
Automatically package and test a Python project against configurable
Python2 and Python3 based virtual environments. Environments are
setup by using virtualenv. Configuration is generally done through an
INI-style "tox.ini" file.
i(   t   with_statementN(   t   NormalizedVersiont   IrrationalVersionError(   t
   VirtualEnv(   t   parseconfig(   t	   ResultLog(   t   STDOUTc           C  s   t  j j j   S(   N(   t   pyt   stdt   time(    (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   now   s    c         C  sZ   t  |   } | j j r1 t |  t d   n% | j j rV t |  t d   n  | S(   Ni    (   R   t   optiont   helpt	   show_helpt
   SystemExitt   helpinit   show_help_ini(   t   argst   config(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   prepare   s    

c         C  s   y. t  |   } t |  j   } t |   Wn] t k
 rM t d   nA t j j k
 r } t d   } | j
 | j  t d   n Xd  S(   Ni   i   (   R   t   Sessiont
   runcommandR   t   KeyboardInterruptt   toxt	   exceptiont   MinVersionErrort   Reportert   Nonet   errort   message(   R   R   t   retcodet   et   r(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   main$   s    c         C  s`   t  j j   } | j |  j j    | j   | j d d t | j d  | j d  d  S(   Ns   Environment variablest   boldsB   TOXENV: comma separated list of environments (overridable by '-e')st   TOX_TESTENV_PASSENV: space-separated list of extra environment variables to be passed into test command environments(   R   t   iot   TerminalWritert   writet   _parsert   _format_helpt   linet   True(   R   t   tw(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   1   s    
c         C  s   t  j j   } | j d d  x\ |  j D]Q } | j d | j d | j d | j f d t	 | j | j
  | j   q) Wd  S(   Nt   -s   per-testenv attributess   %-15s %-8s default: %st   <t   >R"   (   R   R#   R$   t   sept   _testenv_attrR(   t   namet   typet   defaultR)   R   (   R   R*   t   env_attr(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   =   s    	(t   Actionc           B  sk   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d	 d	 e	 e
 e
 d  Z d   Z d	 d  Z RS(
   c         C  s   | |  _  | |  _ | j d d  d |  _ | |  _ | j |  _ | |  _ | r[ | j j p^ d |  _	 g  |  _
 |  j  r |  j  j |  _ n	 d |  _ | d k r d } n d } | j j |  j  } | j |  |  _ d  S(	   Nt    i   i    R   t   GLOBt   runtestst   testt   setup(   t   venvt   msgt   splitt   activityt   sessiont   reportR   t	   envconfigt   envnamet   idt
   _popenlistR0   t   venvnamet	   resultlogt
   get_envlogt   get_commandlogt
   commandlog(   t   selfR>   R:   R;   R   t   catt   envlog(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   __init__H   s     								c         C  s   |  j  j |   d  S(   N(   R?   t   logaction_start(   RI   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt	   __enter__\   s    c         G  s   |  j  j |   d  S(   N(   R?   t   logaction_finish(   RI   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   __exit___   s    c         C  s3   | |  _  |  j j d |  j | | f d t d  S(   Ns	   %s %s: %sR"   (   R=   R?   t
   verbosity0RD   R)   (   RI   R0   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   setactivityb   s    	c         C  s*   |  j  j d |  j | | f d t d  S(   Ns	   %s %s: %sR"   (   R?   t
   verbosity1RD   R)   (   RI   R0   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   infof   s    c         C  s   |  j  r |  j  j j } n |  j j j } y | j d |  } Wn- t j j	 k
 rp | j
 d d  g  } n Xt |  } | j d | | f  } | j d  } | j   | S(   Ns   %s-*t   diri   s	   %s-%s.logt   w(   R:   R@   t	   envlogdirR>   R   t   logdirt   listdirR   R   t   ENOENTt   ensuret   lent   joint   opent   flush(   RI   t   actionidRX   t   lt   numt   patht   f(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   _initlogpathi   s    	

c      	   C  s$  d  } } |  j j j j }	 |	 s( | r |  j |  j  }
 |
 j d |  j |  j | | f  |
 j	   t
 j j |
 j  |  _ } | j   } | j   |
 } n | r t j } n  | d  k r t
 j j   } n  y( |  j | | d | d | d t } Wn6 t k
 r2} |  j j d | j | | f    n X| | _ g  | D] } t |  ^ qC| _ | | _ |  | _ |  j j |  zu|  j j  | d | y|	 r| r| j! d  k st"  d  } t#   } x | j$   } | j d  } | r<t% j& j |  d | k s t#   | d k rt% j& j	   t#   } qq| j'   d  k	 rq| j& d  k	 rm| j& j(   n  Pqt
 j) j* j+ d  | j, |  q| j(   n | j-   \ } } Wn1 t. k
 r|  j j/   | j0   t.    n X| j0   } Wd  |  j j1 |  X| r| rd	 j2 t3 t | j   } | r|  j j d
 | | f  | j   } |  j j |  t4 |  d  r|  j5 j6 | j | |  n  t7 j8 j9 d | | f |   qt7 j8 j9 d | f |   n  | r| r| j   } n  t4 |  d  r |  j5 j6 | j | |  n  | S(   Ns*   actionid: %s
msg: %s
cmdargs: %r
env: %s

t   envt   stdoutt   stderrs/   invocation failed (errno %d), args: %s, cwd: %si   s   
g?R5   s-   invocation failed (exit code %d), logfile: %sRH   s   %s (see %s)s   %r(:   R   R>   R   R   t
   resultjsonRe   RB   R%   R;   R_   R   Rc   t   localR0   t   popen_outpathR^   t   readt
   subprocesst   PIPEt   _popenR   t   OSErrorR?   R   t   errnot   outpatht   strR   t   cwdt   actionRC   t   appendt   logpopenRh   t   AssertionErrorR
   t   tellt   sysRg   t   pollt   closeR   R	   t   sleept   seekt   communicateR   t   keyboard_interruptt   waitt   removeR]   t   mapt   hasattrRH   t   add_commandR   R   t   InvocationError(   RI   R   Rt   Rf   t   redirectt	   returnoutt
   ignore_retRg   Rr   Ri   t   foutt   fint   popenR   t   xt   outt	   last_timet   fin_post   datat   errt   rett   invoked(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   y   s    
	

		"			
	c         C  s   g  } xW | D]O } t  j d k rI t | t j j  rI | j |  } n  | j t |   q Wt  j d k r t	 j j
 t | d   d j   } | d k r |  j r t |  j j j  g | } q n  | S(   Nt   win32i    i   s   .py(   Rz   t   platformt
   isinstanceR   Rc   Rj   t   bestrelpathRv   Rs   t   ost   splitextt   lowerR:   R@   t	   envpython(   RI   Rt   R   t   newargst   argt   ext(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   _rewriteargs   s    $&"c         C  sj   |  j  | |  } | d  k r0 t j j   } n  |  j j | d t d t |  d t	 d | d | d | S(   Nt   shellRt   t   universal_newlinesRg   Rh   Rf   (
   R   R   R   t   environt   copyR>   R   t   FalseRs   R)   (   RI   R   Rt   Rg   Rh   Rf   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRo      s    !N(   t   __name__t
   __module__RL   RN   RP   RR   RT   Re   R   R)   R   R   R   Ro   (    (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR4   G   s   						U	R   c           B  s   e  Z d  Z d   Z e d    Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   R+   c         C  s(   t  j j   |  _ | |  _ g  |  _ d  S(   N(   R   R#   R$   R*   R>   t   _reportedlines(   RI   R>   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRL      s    	c         C  s!   |  j  r |  j  j j j Sd Sd  S(   Ni   (   R>   R   R   t	   verbosity(   RI   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR      s    	c         C  se   d j  t t | j   } | j rG |  j d | j | | j f  n |  j d | j | f  d S(   s;    log information about the action.popen() created process. R5   s     %s$ %s >%ss	     %s$ %s N(   R]   R   Rs   R   Rr   RS   Rt   (   RI   R   Rf   t   cmd(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRw      s    	#c         C  sl   | j  d d j t t | j   } |  j d | j | f d t t | d  s\ t	  t
   | _ d  S(   NR5   s   %s start: %sR"   t
   _starttime(   R;   R]   R   Rs   R   t
   verbosity2RD   R)   R   Rx   R
   R   (   RI   Ru   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRM      s    & c         C  sG   t    | j } |  j d | j | j | f d t t | d  d  S(   Ns    %s finish: %s after %.2f secondsR"   R   (   R
   R   R   RD   R;   R)   t   delattr(   RI   Ru   t   duration(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRO     s    	c         C  s   |  j  j d d  d  S(   Nt   _t   summary(   R*   R.   (   RI   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   startsummary  s    c         C  s#   |  j  d k r |  j |  n  d  S(   Ni   (   R   t   logline(   RI   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRT     s    c         C  s0   |  j  d k r, |  j d | f d t n  d  S(   Ni   s   using %sR"   (   R   R   R)   (   RI   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   using  s    c         C  s   |  j  d  d  S(   Nt   KEYBOARDINTERRUPT(   R   (   RI   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR     s    c         C  sS   | j  d  r | d 7} n  |  j j | d t |  j j |  |  j j   d  S(   Nt   :R5   R"   (   t   endswithR*   R%   R)   R(   (   RI   R0   t   value(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   keyvalue  s
    c         K  s   |  j  | |  d  S(   N(   R   (   RI   R;   t   opts(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR(   $  s    c         C  s   |  j  | d t d  S(   Nt   green(   R   R)   (   RI   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   good'  s    c         C  s   |  j  d | d t d  S(   Ns   WARNING:t   red(   R   R)   (   RI   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   warning*  s    c         C  s   |  j  d | d t d  S(   Ns   ERROR: R   (   R   R)   (   RI   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   -  s    c         C  s   |  j  d | d t d  S(   Ns   SKIPPED:t   yellow(   R   R)   (   RI   R;   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   skip0  s    c         K  s+   |  j  j |  |  j j d | |  d  S(   Ns   %s(   R   Rv   R*   R(   (   RI   R;   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   3  s    c         K  s*   |  j  d k r& |  j d | |  n  d  S(   Ni    s   %s(   R   R   (   RI   R;   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRQ   7  s    c         K  s*   |  j  d k r& |  j d | |  n  d  S(   Ni   s   %s(   R   R   (   RI   R;   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRS   ;  s    c         K  s*   |  j  d k r& |  j d | |  n  d  S(   Ni   s   %s(   R   R   (   RI   R;   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   ?  s    (   R   R   t
   actioncharRL   t   propertyR   Rw   RM   RO   R   RT   R   R   R   R(   R   R   R   R   R   RQ   RS   R   (    (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR      s(   																	R   c           B  s   e  Z d  Z e j e d  Z e d    Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z e e d  Z d   Z d   Z d   Z RS(   sn    (unstable API).  the session object that ties
    together configuration, reporting, venv creation, testing. c         C  s  | |  _  | |  _ t   |  _ | |   |  _ |  j | j  | j j d d  |  j j d |  j  j	 f  i  |  _
 i  |  _ y/ g  |  j  j D] } |  j |  ^ q |  _ WnW t k
 r t d   n; t j j k
 r} |  j j t |   t d   n Xg  |  _ d  S(   NRU   i   s   tox.ini: %s(   R   R   R   RE   R?   t   make_emptydirRX   R[   R   t
   toxinipatht	   _spec2pkgt
   _name2venvt   envlistt   getvenvt   venvlistt   LookupErrorR   R   R   t   ConfigErrorR   Rs   t   _actions(   RI   R   R   t   ReportR   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyRL   K  s$    				,c         C  s   |  j  j j S(   N(   R   t   pluginmanagert   hook(   RI   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   b  s    c         C  s   |  j  j j | d   } | d  k rG |  j j d |  t |   nG | j |  j  j k r |  j j d | | j f  t	 j
 j d   n  t d | d |   } | |  j | <| S(   Ns   unknown environment %rs"   venv %r in %s would delete projects   envdir must not equal toxinidirR@   R>   (   R   t
   envconfigst   getR   R?   R   R   t   envdirt	   toxinidirR   R   R   R   R   (   RI   R0   R@   R:   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt	   _makevenvf  s    	c         C  s1   y |  j  | SWn t k
 r, |  j |  SXd S(   s;    return a VirtualEnv controler object for the 'name' env.  N(   R   t   KeyErrorR   (   RI   R0   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   s  s    c         G  s)   t  |  | | |  } |  j j |  | S(   N(   R4   R   Rv   (   RI   R:   R;   R   Ru   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt	   newactionz  s    c         C  s   |  j  j d t j t j f  |  j j j r< |  j   nx |  j j j rs |  j	 d t
 d |  j j j d k  nA |  j j j r |  j	 d t d |  j j j d k  n
 |  j   Sd  S(   Ns   tox-%s from %st   all_envst   descriptioni    (   R?   R   R   t   __version__t   __file__R   R   t
   showconfigt   listenvst   showenvsR   R   t   listenvs_allR)   t   subcommand_test(   RI   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR     s     ((c         C  s   x | D]y } | j  |  } | j   sN |  j j d | f  t d   n  | j  |  } | j   j d d  | j |  q Wd  S(   Ns   missing source file: %si   RU   (   R]   t   checkR?   R   R   t   dirpathR[   R   (   RI   t   srcdirt   pathlistt   destdirt   relpatht   srct   target(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt
   _copyfiles  s    c         C  s  |  j  j j d  } | j   s6 t j j |   n  |  j d  d  } | 9| j	 d |  |  j
 |  j  j  | j t j | d d d |  j  j g d |  j  j y |  j  j j   d SWn t j j k
 rg  } t t |   A } x7 | D]/ } | r| d d	 k rq n  | j |  q WWd  QXd
 j |  j   sc|  j j d  t d   n  |  j j d  t d   n XWd  QXd  S(   Ns   setup.pyt	   packagings
   sdist-maket   sdists   --formats=zips
   --dist-dirRt   i    t   #t    s   setup.py is emptyi   sT   No dist directory found. Please check setup.py, e.g with:
     python setup.py sdist(   R   t   setupdirR]   R   R   R   t   MissingFileR   R   RR   R   t   distdirR   Rz   t
   executableRY   R   R   RZ   R^   Rs   Rv   t   stripR?   R   (   RI   R9   Ru   R   t   fpR(   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt
   _makesdist  s4    		c         C  sV   | j    rR |  j j d |  t j j j t |  d t | j	 d d  n  d  S(   Ns     removing %st   ignore_errorsRU   i   (
   R   R?   RT   R   R   t   shutilt   rmtreeRs   R)   R[   (   RI   Rc   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR     s    c      	   C  s  | j    s d | _ d  S|  j | d | j j  } |  d | _ |  j j | j  } y | j d |  } Wn' t	 j
 j k
 r t j   d } n X| r | j d  } | j d g t |  d  | | _ |  j j t |   t S| j d  } | j |  t SWd  QXd  S(	   Ns   platform mismatcht   getenvi    Ru   i   R9   s   setup virtualenvt   python(   t   matching_platformt   statusR   R@   R   RE   RF   R0   t   updateR   R   R   Rz   t   exc_infoRG   R   Rs   R?   R   R   t   getcommandpatht   set_python_infoR)   (   RI   R:   Ru   RK   R   RH   t   commandpath(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   setupenv  s(    			c         C  s1   |  j  | d  } |  | j   t SWd  QXd  S(   Nt
   finishvenv(   R   t   finishR)   (   RI   R:   Ru   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR     s    
c      	   C  sl   |  j  | d |  } | K y | j | |  t SWn+ t j j k
 ra t j   d | _ t	 SXWd  QXd  S(   Nt
   developpkgi   (
   R   R  R)   R   R   R   Rz   R   R   R   (   RI   R:   R   Ru   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR    s    c      	   C  s   |  j  j d t j j |   |  j | d |  } | K y | j | |  t SWn+ t j	 j
 k
 r t j   d | _ t SXWd QXd S(   s  Install package in the specified virtual environment.

        :param :class:`tox.config.VenvConfig`: Destination environment
        :param str path: Path to the distribution package.
        :return: True if package installed otherwise False.
        :rtype: bool
        t
   installpkgi   N(   RE   t
   set_headerR   Rc   Rj   R   R  R)   R   R   R   Rz   R   R   R   (   RI   R:   Rc   Ru   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR    s    c         C  sj  |  j  j j r{ |  j  j s+ |  j  j j r{ |  j  j j } | sO |  j  j } n  |  j |  } |  j j d t |   n y |  j	   } Wn< t
 j j k
 r t j   d } |  j j d |  d SX|  j  j j | j  } | | k rf|  j j d t |   y | j   j d d  Wn1 t j j k
 rU|  j j d | j    qfX| j |  n  | S(   sQ   
        :return: Path to the distribution
        :rtype: py.path.local
        s,   using package %r, skipping 'sdist' activity i   s'   FAIL could not package project - v = %rNs   copying new sdistfile to %rRU   s   could not copy distfile to %s(   R   R   t	   sdistonlyt   sdistsrcR  t   _resolve_pkgR?   RT   Rs   R   R   R   R   Rz   R   R   t	   distshareR]   t   basenameR   R[   R   t   ErrorR   R   (   RI   Rc   t   vt	   sdistfile(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   get_installpkg_path  s4    c   	      C  s  |  j  j r% |  j j d  d  } n |  j   } | s; d S|  j  j j rN d  Sx<|  j D]1} |  j	 |  rX | j
 j r |  j | |  j  j  n8 |  j  j s | j
 j r |  j |  n |  j | |  |  j | d  } |  | j
 j } | j | d |  j  j d | } | j d  d } | j   j d  } | j d	 d
 j |   |  j j | j  } | j |  Wd  QX|  j |  qX qX W|  j   } | S(   Ns   skipping sdist stepi   t	   envreportRt   Ru   s   

is   
t	   installedt   ,(   R   t	   skipsdistR?   RT   R   R  R   R  R   R   R@   t
   usedevelopR  R   t   skip_installR   R  R   t   list_dependencies_commandt   _pcallR   R<   R   RR   R]   RE   RF   R0   t   set_installedt
   runtestenvt   _summary(	   RI   Rc   R:   Ru   R   t   outputt   packagesRK   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR     s:    		c         C  sb   |  j  j j sU | j r d  S|  j j d |  | j d |  |  j j d |  n	 d | _ d  S(   NR:   R   s   skipped tests(   R   R   t   notestR   R   t   tox_runtest_preR8   t   tox_runtest_post(   RI   R:   R   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR  9  s    	c         C  s  |  j  j   d } xx|  j D]m} | j } t | t j j  r d | j j	 t
 |  f } |  j j j r |  j  j |  qd } |  j  j |  q | d k r d | j j	 t
 |  f } |  j  j |  q | r| d k rd | j j	 t
 |  f } |  j  j |  q | r[| d k r[d | j j	 t
 |  f } |  j  j |  d } q | sjd } n  |  j  j d | j j	 | f  q W| s|  j  j d  n  |  j j j } | rt j j |  } | j |  j j    |  j  j d	 |  n  | S(
   Ni    s     %s: %si   s   platform mismatchs   ignored failed commands   skipped testss   commands succeededs     congratulations :)s   wrote json report at: %s(   R?   R   R   R   R   R   R   t   InterpreterNotFoundR@   RA   Rs   R   R   t   skip_missing_interpretersR   R   R   Ri   R   Rc   Rj   R%   RE   t
   dumps_jsonR(   (   RI   R   R:   R   R;   Rc   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR  C  s>    			$c         C  sM  |  j    |  j j d |  j j j  |  j j d |  j j  |  j j d |  j j  |  j j d |  j j  |  j j d |  j j	  |  j j d |  j j
  |  j j d |  j j  |  j j j   xz |  j j j   D]f } |  j j d | j d	 t x@ |  j j j D]/ } |  j j d
 | j t | | j  f  qWq Wd  S(   Ns   config-file:s   toxinipath: s   toxinidir:  s   toxworkdir: s   setupdir:   s   distshare:  s   skipsdist:  s   [testenv:%s]R"   s     %-15s = %s(   t   info_versionsR?   R   R   R   t
   configfileR   R   t
   toxworkdirR   R  R  R*   R(   R   t   valuesRA   R)   R&   R/   R0   t   getattr(   RI   R@   t   attr(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   g  s    
c           s   j  j   j  j } | rI t g   D] } | | k r( | ^ q(  n g  }   r  j j d  t d   | | D   n       f d   } x | D] } | |  q W| r  r  j j d   j j d  n  x | D] } | |  q Wn  d  S(   Ns   default environments:c         s  s   |  ] } t  |  Vq d  S(   N(   R\   (   t   .0Rf   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pys	   <genexpr>}  s    c           sW     r=  |  j  p d } d j |  j   |  j   } n |  }  j j |  d  S(   Ns   [no description]s
   {0} -> {1}(   R   t   formatt   ljustR   R?   R(   (   R   t   textR;   (   R   t   env_conft
   max_lengthRI   (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt
   report_env  s
    $R   s   additional environments:(   R   R   R   t   sortedR?   R(   t   max(   RI   R   R   R2   R   t   extraR-  (    (   R   R+  R,  RI   s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   w  s    7c         C  s   d t  j g } y t j j d  } Wn' t j j j k
 rO | j d  n X| j d | j    |  j j	 d d j
 |   d  S(   Ns   tox-%ss   virtualenv --versions   virtualenv-1.9.1 (vendored)s   virtualenv-%ss   tool-versions:R5   (   R   R   R   t   processt   cmdexecR
  Rv   R   R?   R   R]   (   RI   t   versionst   version(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR!    s    c         C  sB   y |  j  | SWn, t k
 r= |  j |  |  j  | <} | SXd  S(   N(   R   R   t   _resolvepkg(   RI   t   pkgspecR   (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR    s
    c         C  su  t  j j t |   s | St j j |  } | j   r> | S| j   j d d  sq t j	 j
 | j     n  |  j j d |  | j   j | j  } t |  d k r t j	 j |   n  t |  d k rig  } xY | D]Q } t | j  } | d  k	 r| j | | f  q |  j j d t |   q W| j   | s]t j	 j |   n  | d d S| d Sd  S(   NRU   i   s   determining %si    s"   could not determine version of: %si(   R   Rc   t   isabsRs   R   Rj   R   R   R   R   t   MissingDirectoryR?   RT   RY   R	  R\   t   MissingDependencyt
   getversionR   Rv   R   t   sort(   RI   R6  t   pt
   candidatest   itemsR   t   ver(    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR5    s0    
(   R   R   t   __doc__Rm   t   PopenR   RL   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R   R   R  R  R   R   R!  R  R5  (    (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR   G  s.   					
	 				
		"	%
	$		
	s!   [\w_\-\+\.]+-(.*)(\.zip|\.tar.gz)c         C  sU   t  j |   } | d  k r d  S| j d  } y t |  SWn t k
 rP d  SXd  S(   Ni   (   t   _rex_getversiont   matchR   t   groupR   R   (   R	  t   mR4  (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyR:    s    (!   R@  t
   __future__R    R   R   R   Rz   Rm   t   tox._verlibR   R   t   tox.venvR   t
   tox.configR   t
   tox.resultR   R   R
   R   R   R!   R   R   t   objectR4   R   R   R   t   ret   compileRB  R:  (    (    (    s(   /tmp/pip-build-UnxK1c/tox/tox/session.pyt   <module>   s,   				
` w