
@^Yc           @   s5  d  d l  Z  d  d l Z d  d l 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
 Z
 d  d l Z d  d l m Z d  d l Z d  d l m Z d  d l m Z d  d l Z d  d l Z e j d k Z i d d 6d d 6d	 d	 6e j d
 6d d 6d d 6Z x/ d j d  D] Z d e e  e d
 e <q.We j d  Z e   Z f  d  Z d f  d     YZ  d f  d     YZ! d f  d     YZ" d f  d     YZ# d f  d     YZ$ e% f  d  Z& e' d  Z( d  e  j) f d!     YZ* d" f  d#     YZ+ e d$    Z, d% e f d&     YZ- d' f  d(     YZ. d) Z/ d*   Z0 d+   Z1 d, f  d-     YZ2 d.   Z3 d/   Z4 d0   Z5 d1   Z6 d2 f  d3     YZ7 d4 f  d5     YZ8 e j9 d6  j: Z; d7 f  d8     YZ< d9 f  d:     YZ= d; f  d<     YZ> d= e f d>     YZ? d?   Z@ d S(@   iN(   t   fnmatchcase(   t   list2cmdline(   t	   hookspecs(   t   NormalizedVersiont   win32t   jythont   pypyt   pypy3t   pyt   python2t   py2t   python3t   py3s   26,27,32,33,34,35,36,37t   ,s   python%s.%st   toxc         C   s   d d  l  } t j d  } | j t  | j | j  | j | j  | j | j  | j | j	  | j
 d  x |  D] } | j |  q| W| j   | S(   NiR   (   t   tox.venvt   pluggyt   PluginManagert   add_hookspecsR   t   registert   configt   interpreterst   venvt   sessiont   load_setuptools_entrypointst   check_pending(   t   pluginsR   t   pmt   plugin(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   get_plugin_manager"   s    
t   Parserc           B   sJ   e  Z d  Z d   Z d   Z d d d  Z d   Z d   Z d   Z	 RS(   s-    command line and ini-parser control object. c         C   s(   t  j d d d t  |  _ g  |  _ d  S(   Nt   descriptions   tox optionst   add_help(   t   argparset   ArgumentParsert   Falset	   argparsert   _testenv_attr(   t   self(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   __init__5   s    	c         O   s   |  j  j | |   S(   s    add argument to command line parser.  This takes the
        same arguments that ``argparse.ArgumentParser.add_argument``.
        (   R$   t   add_argument(   R&   t   argst   kwargs(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR(   :   s    c         C   s&   |  j  j t | | | | |   d S(   s   add an ini-file variable for "testenv" section.

        Types are specified as strings like "bool", "line-list", "string", "argv", "path",
        "argvlist".

        The ``postprocess`` function will be called for each testenv
        like ``postprocess(testenv_config=testenv_config, value=value)``
        where ``value`` is the value as read from the ini (or the default value)
        and ``testenv_config`` is a :py:class:`tox.config.TestenvConfig` instance
        which will receive all ini-variables as object attributes.

        Any postprocess function must return a value which will then be set
        as the final value in the testenv section.
        N(   R%   t   appendt   VenvAttribute(   R&   t   namet   typet   helpt   defaultt   postprocess(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   add_testenv_attribute@   s    c         C   sh   t  | d  s t  t  | d  s* t  t  | d  s? t  t  | d  sT t  |  j j |  d S(   s    add an ini-file variable as an object.

        This works as the ``add_testenv_attribute`` function but expects
        "name", "type", "help", and "postprocess" attributes on the object.
        R-   R.   R/   R1   N(   t   hasattrt   AssertionErrorR%   R+   (   R&   t   obj(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   add_testenv_attribute_objQ   s
    c         C   s   |  j  j |  S(   N(   R$   t
   parse_args(   R&   R)   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   _parse_args]   s    c         C   s   |  j  j   S(   N(   R$   t   format_help(   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   _format_help`   s    N(
   t   __name__t
   __module__t   __doc__R'   R(   t   NoneR2   R6   R8   R:   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR   2   s   				R,   c           B   s   e  Z d    Z RS(   c         C   s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R-   R.   R0   R/   R1   (   R&   R-   R.   R0   R/   R1   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'   e   s
    				(   R;   R<   R'   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR,   d   s   t	   DepOptionc           B   sA   e  Z d  Z d Z d Z d Z d   Z d   Z e d    Z	 RS(   t   depss	   line-lists:   each line specifies a dependency in pip/setuptools format.c   
      C   s   g  } | j  } x | D]z } t j d |  } | rV | j   \ } } | j | }	 n | j   } d  }	 |  j | |  } | j t	 | |	   q W| S(   Ns   :(\w+):\s*(\S+)(
   R   t   ret   matcht   groupst   indexservert   stripR>   t   _replace_forced_depR+   t	   DepConfig(
   R&   t   testenv_configt   valueR@   R   t   deplinet   mt   inameR-   t   ixserver(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR1   s   s    	c         C   sA   | j  j s | Sx* | j  j D] } |  j | |  r | Sq W| S(   s5  
        Override the given dependency config name taking --force-dep-version
        option into account.

        :param name: dep config, for example ["pkg==1.0", "other==2.0"].
        :param config: Config instance
        :return: the new dependency that should be used for virtual environments
        (   t   optiont	   force_dept   _is_same_dep(   R&   R-   R   t
   forced_dep(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRF      s    	c         C   sP   t  j j |  j } y t  j j |  j } Wn t  j k
 rE t SX| | k S(   sy   
        Returns True if both dependency definitions refer to the
        same package, even if versions differ.
        (   t   pkg_resourcest   Requirementt   parset   project_namet   RequirementParseErrorR#   (   t   clst   dep1t   dep2t	   dep1_namet	   dep2_name(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRP      s    (    (
   R;   R<   R-   R.   R/   R0   R1   RF   t   classmethodRP   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR?   m   s   		t   PosargsOptionc           B   s)   e  Z d  Z d Z e Z d Z d   Z RS(   t   args_are_pathst   bools*   treat positional args in commands as pathsc         C   s   | j  } | j j } | r | r g  } xf | j j D]U } | r| | j j | d t } | j   r| | j j |  } q| n  | j	 |  q4 Wn  | j
 j |  n  | S(   Nt   abs(   R   RN   R)   t   invocationcwdt   joint   Truet   checkt	   changedirt   bestrelpathR+   t   _readert   addsubstitutions(   R&   RH   RI   R   R)   t   argt   origpath(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR1      s    	(   R;   R<   R-   R.   Rc   R0   R/   R1   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR]      s
   t   InstallcmdOptionc           B   s)   e  Z d  Z d Z d Z d Z d   Z RS(   t   install_commandt   argvs   pip install {opts} {packages}s8   install command for dependencies and package under test.c         C   s%   d | k r! t  j j d   n  | S(   Ns
   {packages}s8   'install_command' must contain '{packages}' substitution(   R   t	   exceptiont   ConfigError(   R&   RH   RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR1      s    	(   R;   R<   R-   R.   R0   R/   R1   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRk      s
   c         C   s  t  |  } |  d k r( t j d }  n  t   } | j j d |  | j |   } t j	 j
 d | j  } t d | d | d |  } | | _ | j | _ | j j } t j j |  r t j j |  } n t j j |  rt j j t j j | d   } n x t j j   j d t  D]% }	 |	 j |  } | j   r Pq q Wt j j   j d	  } | j   s| j p|| j }
 t d
 | d |
 |
 r| Sn  y t | |  WnA t j j k
 rt j    d } t j! j" d t# |   n X| j j$ d |  | S(   s   
    :param list[str] args: Optional list of arguments.
    :type pkg: str
    :rtype: :class:`Config`
    :raise SystemExit: toxinit file is not found
    i   t   parsert   hookt   pluginmanagerRN   R   s   tox.init   reverses	   setup.cfgs   toxini file %r not foundt   sysexits   ERROR: R   N(%   R   R>   t   sysRm   R   Rq   t   tox_addoptionR8   R   R   t   Interpreterst   Configt   _parserR%   RN   t
   configfilet   ost   patht   isfileR   t   localt   isdirRb   t   partsRc   Rd   R/   t   helpinit   feedbackt   parseiniRn   t   InterpreterNotFoundt   exc_infot   builtint   print_t   strt   tox_configure(   R)   R   R   Rp   RN   R   R   t   basenamet   inipathR|   t   helpoptionst   exn(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   parseconfig   sB    		$"c         C   s6   t  j j d |  d t j | r2 t d   n  d  S(   Ns   ERROR: t   filei   (   R   R   R   Ru   t   stderrt
   SystemExit(   t   msgRt   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR      s    t   VersionActionc           B   s   e  Z d    Z RS(   c         O   s6   t  j } t j j d | t  j f  t d   d  S(   Ns   %s imported from %si    (   R   t   __version__R   R   R   t   __file__R   (   R&   R$   R)   R*   t   version(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   __call__  s    	(   R;   R<   R   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s   t
   SetenvDictc           B   sA   e  Z d    Z d   Z d d  Z d   Z d   Z d   Z RS(   c         C   s(   | |  _  | |  _ i  |  _ g  |  _ d  S(   N(   t   readert   definitionst   resolvedt   _lookupstack(   R&   t   dictR   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'     s    			c         C   s   | |  j  k S(   N(   R   (   R&   R-   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   __contains__  s    c         C   s   y |  j  | SWn t k
 r y/ | |  j k r@ t |   n  |  j | } Wn! t k
 rq t j j | |  SX|  j j |  z! |  j j	 |  |  j  | <} Wd  |  j j
   X| SXd  S(   N(   R   t   KeyErrorR   R   R{   t   environt   getR+   R   t   _replacet   pop(   R&   R-   R0   t   valt   res(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s    !c         C   s1   |  j  | t  } | t k r- t |   n  | S(   N(   R   t   _dummyR   (   R&   R-   t   x(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   __getitem__&  s    c         C   s   |  j  j   S(   N(   R   t   keys(   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR   ,  s    c         C   s   | |  j  | <| |  j | <d  S(   N(   R   R   (   R&   R-   RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   __setitem__/  s    N(	   R;   R<   R'   R   R>   R   R   R   R   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s   				c   
      C   s  |  j  d d d d t d d d d |  j  d	 d
 d d d d d d |  j  d d d d d d d d |  j  d d d d d d d d d |  j  d d d d d |  j  d d d d d d d d |  j  d d d d d d d d |  j  d  d d! d d" d d# d d$ |  j  d% d d& d d' d( d) d d* |  j  d+ d d d d, d d- |  j  d. d d d d/ d d0 |  j  d1 d d! d d  d( d2 d d3 |  j  d4 d d d d5 d d6 |  j  d7 d d& d d8 d( d9 d d: |  j  d; d d d d< d d= |  j  d> d? d d d d@ d dA |  j  dB d d! d dC d( d2 d dD |  j  dE d d! d( dF d d  d dG |  j  dH d d& d( dI d d  d dJ |  j  dK d d d dL |  j  dM d d d dN |  j  dO d d d dP |  j  dQ d d! d dR d( d2 d d  d dS |  j  dT d dU d dV |  j dW dX dY dZ d d[ d d\  d]   } |  j dW d^ dY d_ d` | d da  db   } |  j dW dc dY dd d d  d` | d de  df   } |  j dW dg dY dd d dh d` | d di  |  j dW dj dY dZ d dk d dl  |  j dW dm dY dZ d dn d do  |  j dW dp dY dd d d  d dq  |  j dW dr dY dZ d ds d dt  |  j t    |  j dW du dY dv d t d dw  |  j dW dx dY dv d t d dy  dz   } |  j dW d@ dY dv d t d` | d d{  d|   } |  j dW d} dY d~ d` | d d  |  j dW d dY d~ d d  |  j dW d dY dd d d d d  d   } d   } |  j dW d dY dv d t d` | d d  |  j dW d dY dv d t d` | d d  d   } |  j dW d dY dv d t d` | d d  d   }	 |  j dW d dY dv d` |	 d t d d  |  j t    |  j dW d dY d d d d d  |  j t    |  j dW d dY d d dh d d  |  j d dY dv d t d d |  j d dY d~ d d d  S(   Ns	   --versiont   nargsi    t   actiont   destR   R/   s%   report version information to stdout.s   -hs   --helpt
   store_trues   show help about optionss
   --help-inis   --hiR   s   show help about ini-namess   -vt   countt	   verbosityR0   sf   increase verbosity of reporting output. -vv mode turns off output redirection for package installations   --showconfigs5   show configuration information for all environments. s   -ls
   --listenvst   listenvss<   show list of test environments (with description if verbose)s   -as   --listenvs-allt   listenvs_allsB   show list of all defined environments(with description if verbose)s   -ct   stores   tox.iniRz   s2   config file name or directory with 'tox.ini' file.s   -eR+   t   envt   metavart   envlists6   work against specified environments (ALL selects all).s   --notestt   notests   skip invoking test commands.s   --sdistonlyt	   sdistonlys*   only perform the sdist packaging activity.s   --installpkgt   PATHsO   use specified package for installation into venv, instead of creating an sdist.s	   --developt   developsC   install package in the venv using 'setup.py develop' via 'pip -e .'s   -it   indexurlt   URLse   set indexserver url (if URL is of form name=url set the url for the 'name' indexserver, specifically)s   --pret   pres   install pre-releases and development versions of dependencies. This will pass the --pre option to install_command (pip by default).s   -rs
   --recreatet   recreates(   force recreation of virtual environmentss   --result-jsont
   resultjsonsT   write a json file with detailed information about all commands and results involved.s
   --hashseedt   SEEDs   set PYTHONHASHSEED to SEED before running commands.  Defaults to a random integer in the range [1, 4294967295] ([1, 1024] on Windows). Passing 'noset' suppresses this behavior.s   --force-dept   REQs   Forces a certain version of one of the dependencies when configuring the virtual environment. REQ Examples 'pytest<2.7' or 'django>=1.6'.s   --sitepackagess1   override sitepackages setting to True in all envss   --alwayscopys/   override alwayscopy setting to True in all envss   --skip-missing-interpreterss)   don't fail tests for missing interpreterss	   --workdirt   workdirs   tox working directoryR)   t   *sA   additional arguments available to command positional substitutionR-   t   envdirR.   R|   s   {toxworkdir}/{envname}sy   set venv directory -- be very careful when changing this as tox will remove this directory when recreating an environmentc         S   s>   | } |  j  } d | k r: | j d  k	 r: | j | d <n  | S(   Nt   PYTHONHASHSEED(   R   t   hashseedR>   (   RH   RI   t   setenvR   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s
    	R   t   dict_setenvR1   s4   list of X=Y lines with environment variable settingsc         S   sE   | d  k r; x% |  j D] } | t k r t | Sq Wt j St |  S(   N(   R>   t   factorst   default_factorsRu   t
   executableR   (   RH   RI   t   f(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   basepython_default  s    t
   basepythont   stringsQ   executable name or path of interpreter used to create a virtual test environment.c         S   s   | j  d d  S(   se   the reader by default joins generated description with new line,
         replace new line with spaces   
t    (   t   replace(   RH   RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   merge_description  s    R   t    s%   short description of this environmentt	   envtmpdirs   {envdir}/tmps   venv temporary directoryt	   envlogdirs   {envdir}/logs   venv log directoryt   downloadcachesD   (ignored) has no effect anymore, pip-8 uses local caching by defaultRe   s   {toxinidir}s,   directory to change to when running commandst   skip_installR_   s   Do not install the current package. This can be used when you need the virtualenv management but do not want to install the current packaget   ignore_errorssW   if set to True all commands will be executed irrespective of their result error status.c         S   s   |  j  j j r t S| S(   N(   R   RN   R   Rc   (   RH   RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s    s&   always recreate this test environment.c         S   sf  t  t j j g  | D] } | j d  ^ q   } t d d d d d g  } t j j d d   } | d  k	 r g  | j   D] } | r} | ^ q} } | j
 |  n  t j d k r| j d	  | j d
  | j d  | j d  | j d  | j d  n | j d  xM | D]E } x< t j D]1 } t | j   | j    r)| j |  q)q)WqW| S(   NR   R   t   PIP_INDEX_URLt   LANGt   LANGUAGEt   LD_LIBRARY_PATHt   TOX_TESTENV_PASSENVR   t   SYSTEMDRIVEt
   SYSTEMROOTt   PATHEXTt   COMSPECt   TEMPt   TMPt   TMPDIR(   t   listt	   itertoolst   chaint   from_iterablet   splitt   setR{   R   R   R>   t   extendRu   t   platformt   addR    t   upper(   RH   RI   R   t   passenvt   pt
   env_valuest   specR-   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s,    	(%R   s	   line-lists  environment variables needed during executing test commands (taken from invocation environment). Note that tox always passes through some basic environment variables which are needed for basic functioning of the Python system. See --showconfig for the eventual passenv setting.t   whitelist_externalssv   each lines specifies a path or basename for which tox will not warn about it coming from outside the test environment.R   s   .*s`   regular expression which must match against ``sys.platform``. otherwise testenv will be skipped.c         S   s   |  j  j j p | S(   N(   R   RN   t   sitepackages(   RH   RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s    c         S   s   |  j  j j p | S(   N(   R   RN   t
   alwayscopy(   RH   RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR   	  s    R   sp   Set to ``True`` if you want to create virtual environments that also have access to globally installed packages.R   sS   Set to ``True`` if you want virtualenv to always copy files rather than symlinking.c         S   s   |  j  j j p | S(   N(   R   RN   R   (   RH   RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   pip_pre  s    R   sK   If ``True``, adds ``--pre`` to the ``opts`` passed to the install command. c         S   s#   |  j  j } | j o" | p" | j S(   N(   R   RN   t
   installpkgR   (   RH   RI   RN   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s    t
   usedevelops(   install package in develop/editable modet   list_dependencies_commandRm   s
   pip freezes+   list dependencies for a virtual environmentt   commandst   argvlists<   each line specifies a test command and can use substitution.t   ignore_outcomesg   if set to True a failing result of this testenv will not make tox fail, only a warning will be producedt   extrassI   list of extras to install with the source distribution or develop install(	   R(   R   R>   R2   R6   R]   R#   Rk   R?   (
   Rp   R   R   R   R   R   R   R   R   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRv   4  s   																#													Rx   c           B   s&   e  Z d  Z d   Z e d    Z RS(   s    Global Tox config object. c         C   s:   i  |  _  t j j   |  _ | |  _ | |  _ | |  _ d  S(   N(   t
   envconfigsR   R|   R~   Ra   R   Rr   RN   (   R&   Rr   RN   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'   A  s
    			c         C   s%   t    } | d  k r! |  j } n  | S(   N(   t   get_homedirR>   t	   toxinidir(   R&   t   homedir(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  J  s    	(   R;   R<   R=   R'   t   propertyR  (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRx   ?  s   		t   TestenvConfigc           B   sh   e  Z d  Z d   Z d   Z e d    Z e d    Z d   Z d   Z	 e d    Z
 d   Z RS(	   s    Testenv Configuration object.
    In addition to some core attributes/properties this config object holds all
    per-testenv ini attributes as attributes, see "tox --help-ini" for an overview.
    c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   envnameR   R   Rg   (   R&   R  R   R   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'   W  s    			c         C   sQ   t  j d k r= d |  j k r= d |  j k r= |  j j d  S|  j j d  Sd S(   s2    path to directory where scripts/binaries reside. R   R   R   t   Scriptst   binN(   Ru   R   R   R   Rb   (   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   get_envbindir`  s
    c         C   s
   |  j    S(   N(   R  (   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt	   envbindiri  s    c         C   s
   |  j    S(   s    path to python executable. (   t   get_envpython(   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt	   envpythonm  s    c         C   s4   d t  |  j  k r d } n d } |  j j |  S(   s#    path to python/jython executable. R   t   python(   R   R   R  Rb   (   R&   R-   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR	  r  s    	c         C   s(   |  j  j j d |  j d |  j  } | S(   sv    return sitepackagesdir of the virtualenv environment.
        (only available during execution, not parsing)
        t   infoR   (   R   R   t   get_sitepackagesdirt   python_infoR   (   R&   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   get_envsitepackagesdirz  s    	c         C   s   |  j  j j d |   S(   s7    return sitepackagesdir of the virtualenv environment. t	   envconfig(   R   R   t   get_info(   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s    c         C   s   t  j d k r< |  j r< d |  j k r< t j j d   n  |  j j j d |   } | j	 su t j j
 |  j   n  | j s t j j d | j | j f   n  | j d	 k  r t j j d   n  | j	 S(
   NR   R   s2   Jython/Windows does not support installing scriptsR  s%   Failed to get version_info for %s: %si   i   s)   python2.5 is not supported anymore, sorry(   i   i   (   Ru   R   R   R   Rn   t   UnsupportedInterpreterR   R   R  R   R   t   version_infot   InvocationErrorR-   t   err(   R&   R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   getsupportedinterpreter  s    					(   R;   R<   R=   R'   R  R  R  R
  R	  R  R  R  (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  R  s   							s   testenv:c           C   s-   y t  j j j   SWn t k
 r( d  SXd  S(   N(   R   R|   R~   t   _gethomedirt	   ExceptionR>   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s    c          C   s4   d }  t  j d k r d }  n  t t j d |    S(   NI    R   i   i   (   Ru   R   R   t   randomt   randint(   t   max_seed(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   make_hashseed  s    	R   c           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c            s9  |   _    j  j     _ t j j   j   |  _ |  j   _   |  _ | j d k r` d } n d  } t
   } | d k r t d |  j d | d d g } d } n3 | s t d |  j d | } d } n t d	     j j d  k r t   } n'   j j d
 k rd  } n   j j } |   _ | j d   j d   j  | j d d     _   j rt |  j j  } t t j  }	 |	 | k  rt j j d |	 | f   qn    j j d  k r| j d d    _ n!   j j   j j d t   _   j j s!| j d t     j _ n  i t! d  d 6  _" d } xQ | j# |  D]@ }
 t$ d   |
 j% d d   \ } } t! | |    j" | <qMWt  }   j j& r0x   j j& D]y } t' j( d |  } | d  k r| } d } n! | j)   \ } } | sd  } n  | d k r#|   j" | _* q| } qWn  | rcx*   j" D] } t! | |    j" | <q@Wn  | j d   j  | j d d    _+ | j d   j+  | j d |    _, | j d   j,  | j d d     _- | j d d    _.   j j d     _/ |  j0 |  \   _1 } |  j2 d!  } | j3 t4  | j5 d"  | j d# d$ t  } | rx- t6 |  D] } | j3 | j% d%   qnWn  xm | D]e } t7 | } t8 | j% d%   } | |  j k s| | k r|  j9 | | | j:      j; | <qqWt<   f d&     j1 D  } | j d' |    _= d  S((   Ns	   setup.cfgR   t   jenkinss   tox:jenkinst   prefixt   fallbacksectionss   {toxworkdir}/distshares   {homedir}/.tox/distshares   invalid contextt   nosetR   R  t
   minversions*   tox version is %s, required is at least %st
   toxworkdirs   {toxinidir}/.toxR`   t   skip_missing_interpretersR0   RD   c         S   s
   |  j    S(   N(   RE   (   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   <lambda>  s    t   =i   s   \W*(\w+)=(\S+)t   ALLt   distdirs   {toxworkdir}/distt	   distsharet   sdistsrct   setupdirs   {toxinidir}t   logt   testenvR  R   R   t   -c         3   s.   |  ]$ } |   j  k o%   j  | j Vq d  S(   N(   R   R   (   t   .0R-   (   R   (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pys	   <genexpr>  s   t	   skipsdist(>   t
   toxinipatht   dirpathR   R   t	   iniconfigt	   IniConfigt   _cfgR   R   R>   t   getcontextnamet   SectionReadert
   ValueErrorRN   R   R  Rh   R  t	   getstringR!  R   R   R   Rn   t   MinVersionErrorR   t   getpathR"  Rb   Rc   R#  t   getboolR#   t   IndexServerConfigRD   t   getlistt   mapR   R   RA   RB   RC   t   urlR'  R(  R)  R*  t   logdirt   _getenvdataR   t   _list_section_factorst   updateR   R   t
   _split_envt   testenvprefixR   t   make_envconfigt   _subsR   t   allR/  (   R&   R   R   R  t   ctxnameR   t   distshare_defaultR   R!  t
   toxversiont   lineR-   R?  t   overridet   urldefRK   t   all_envst   known_factorst   stated_envlistR   t   sectionR   t   all_develop(    (   R   s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'     s    								
		!$		
)c         C   sq   t    } | |  j k rm xR |  j | j   D]: \ } } t j d | t j  } | j t t |    q, Wn  | S(   Ns   ^([\w{}\.,-]+)\:\s+(	   R   R4  t   itemsRA   t   findallt   MRC  t   mapcatt   _split_factor_expr(   R&   RR  R   t   _RI   t   exprs(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRB    s    	 c      	   C   s  t  | j d   } t | |  j d d g d | } t d | d | d | d |  } | j |   | j d |  | j d | j d	 | j d
 | j  x| j	 D]} | j
 }	 |	 d k r t | d |	  }
 |
 | j | j  } na |	 d k r| j | j d d } n: |	 d k r7| j | j d d } n t d |	 f   | j rn| j d | d |  } n  t | | j |  |	 d k r | j i | | j 6  q q W| S(   NR-  R  R,  R   R   R  R   R  t   envsitepackagesdirR
  R_   R|   R   R   R   Rm   R   R   s   space-separated-listt   sepR   s	   line-lists   
s   unknown type %rRH   RI   (   s   bools   paths   strings   dicts   dict_setenvs   argvs   argvlist(   R   R   R6  R4  R  Rh   R  R  R	  R%   R.   t   getattrR-   R0   R=  R7  R1   t   setattr(   R&   R-   RR  t   subsR   R   R   t   vct   env_attrt   atypet   methR   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRF  &  s2    	!	
		c         C   s   |  j  j j p9 t j j d  p9 | j d d t p9 g  } t |  } t	 |  t	 d g  } x@ |  j
 D]5 } | j j t  rk | j | j t t   qk qk W| s | j d  n  | s d | k r t |  } n  | | f S(   Nt   TOXENVR   R   R&  R  (   R   RN   R   R{   R   R   R8  R#   RD  R   R4  R-   t
   startswithRE  R   t   lent   sorted(   R&   R   t   envstrR   RO  RR  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRA  F  s    !(   R;   R<   R'   RB  RF  RA  (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s   	s		 c         C   sO   t  |  t  sB d |  k r6 d j |  j d   }  n  |  g }  n  t t |   S(   s2   if handed a list, action="append" was used for -e s   
R   (   t
   isinstanceR   Rb   R   RW  t   _expand_envstr(   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRD  [  s
    c         C   s2   t  |   } g  | D] } t | j d   ^ q S(   NR-  (   Rj  R   R   (   t   exprt   partial_envst   e(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRX  d  s    c         C   sk   t  j d |   } g  t j | d t D]' \ } } | r( d j |  j   ^ q( } d   } t | |  S(   Ns   ((?:\{[^}]+\})+)|,t   keyR   c         S   s]   t  j d |   } g  | D] } | j d  ^ q } g  t j |   D] } d j |  ^ qD S(   Ns   \{([^}]+)\}R   R   (   RA   R   R   t   productRb   (   R   t   tokenst   tokenR   t   variant(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   expando  s    "(   RA   R   R   t   groupbyR_   Rb   RE   RW  (   Rh  Rp  t   kt   gR   Rs  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRj  i  s
    @	c         C   s   t  t j j t |  |    S(   N(   R   R   R   R   R>  (   R   t   seq(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRW  w  s    RG   c           B   s#   e  Z d d   Z d   Z e Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   R-   RD   (   R&   R-   RD   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'   |  s    	c         C   sF   |  j  r9 |  j  j d k r" |  j Sd |  j  j |  j f St |  j  S(   NR0   s   :%s:%s(   RD   R-   R   (   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   __str__  s
    	N(   R;   R<   R>   R'   Rx  t   __repr__(    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRG   {  s   	R<  c           B   s   e  Z d d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   R-   R?  (   R&   R-   R?  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'     s    	N(   R;   R<   R>   R'   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR<    s   s   {\[[^{}\s]+\]\S+?}R6  c           B   s   e  Z d d d d   Z d   Z d d  Z d   Z d d  Z d d d  Z d d d  Z	 d   Z
 d d	  Z d
 d  Z d
 d  Z d e e d  Z d   Z d d e d  Z RS(   c         C   sk   | d  k r | |  _ n d | | f |  _ | |  _ | p= g  |  _ | |  _ i  |  _ g  |  _ d  |  _ d  S(   Ns   %s:%s(   R>   t   section_nameR4  R  R   RG  t   _subststackt   _setenv(   R&   Rz  t	   cfgparserR  R   R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'     s    				c         C   s/   |  j  d  k r t j j |  S|  j  j |  S(   N(   R|  R>   R{   R   R   (   R&   R-   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   get_environ_value  s    c         K   s&   |  j  j |  | r" | |  _ n  d  S(   N(   RG  RC  t   posargs(   R&   t   _posargst   kw(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyRh     s    c         C   sB   |  j  d } |  j | |  } | d  k	 r> | j | d t Sd  S(   NR   R`   (   RG  R8  R>   Rb   Rc   (   R&   R-   t   defaultpathR   R|   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR:    s    s   
c         C   sT   |  j  | d   } | d  k r" g  Sg  | j |  D] } | j   r2 | j   ^ q2 S(   N(   R8  R>   R   RE   (   R&   R-   R\  t   sR   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR=    s    c         C   s+   |  j  | d   } |  j | d | d | S(   NR0   R\  (   R8  R>   t   _getdict(   R&   R-   R0   R\  RI   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   getdict  s    c         C   sU   |  j  | d  d t d t } |  j | d | d | } t | d |  |  _ |  j S(   NR   t	   crossonlyR0   R\  R   (   R8  R>   Rc   R  R   R|  (   R&   R-   R0   R\  RI   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   getdict_setenv  s    c         C   sw   | d  k r | p i  Si  } xT | j |  D]C } | j   r, | j d d  \ } } | j   | | j   <q, q, W| S(   NR%  i   (   R>   R   RE   (   R&   RI   R0   R\  t   dRL  R-   t   rest(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s    
c         C   s   |  j  | |  } | s! | } n  | d  k rI t d |  j | f   n  t | t  s | j   d k rs t } q | j   d k r t } q t	 j
 j d   n  | S(   Ns   no config value [%s] %s foundt   truet   falses.   boolean value %r needs to be 'True' or 'False'(   R8  R>   R   Rz  Ri  R_   t   lowerRc   R#   R   Rn   Ro   (   R&   R-   R0   R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR;    s    				R   c         C   s(   |  j  | | d t } t j |  |  S(   NR   (   R8  R#   t   _ArgvlistReadert   getargvlist(   R&   R-   R0   R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s    c         C   s   |  j  | |  d S(   Ni    (   R  (   R&   R-   R0   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   getargv  s    c         C   s   d  } xH |  j g |  j D]3 } y |  j | | } PWq t k
 rL q q Xq W| d  k rf | } n |  j |  } | r | r t | d  r |  j | d | d | } n  | S(   NR   R-   R  (   R>   Rz  R  R4  R   t   _apply_factorsR3   R   (   R&   R-   R0   R   R  R   R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR8    s    	c            s@     f d   } | j    j   } d j t d  t | |    S(   Nc            sX   t  j d |   } | s |  S| j   \ } }  t   f d   t |  D  rT |  Sd  S(   Ns   ^([\w{}\.,-]+)\:\s+(.+)c         3   s   |  ] } |   j  k Vq d  S(   N(   R   (   R.  t   fs(   R&   (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pys	   <genexpr>  s    (   RA   t   searchRC   t   anyRX  (   RL  RK   Rk  (   R&   (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   factor_line  s    "s   
(   RE   t
   splitlinesRb   t   filterR>   R>  (   R&   R  R  t   lines(    (   R&   s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s    	c         C   s   d | k r | S| r | n |  j  } |  j j | | f  z t |  d | j |  SWd  |  j j   | | f k s| t  Xd  S(   Nt   {R  (   Rz  R{  R+   t   Replacert
   do_replaceR   R4   (   R&   RI   R-   Rz  R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR     s    N(    (   R;   R<   R>   R'   R~  Rh   R:  R=  R  R  R  R;  R  R  Rc   R#   R8  R  R   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR6    s   				R  c           B   sV   e  Z e j d  e j  Z e d  Z d   Z d   Z	 d   Z
 d   Z d   Z RS(   s   
        (?<!\\)[{]
        (?:(?P<sub_type>[^[:{}]+):)?    # optional sub_type for special rules
        (?P<substitution_value>(?:\[[^,{}]*\])?[^:,{}]*)  # substitution key
        (?::(?P<default_value>[^{}]*))?   # default value
        [}]
        c         C   s   | |  _  | |  _ d  S(   N(   R   R  (   R&   R   R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'     s    	c         C   s   |  j  j |  j |  S(   N(   t   RE_ITEM_REFt   subt   _replace_match(   R&   R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  !  s    c         C   s  | j    } | d } |  j r[ | j d  r; |  j |  S| j   \ } } | j | | !St | j    st t j	 S| d
 k r d | Sy | d } Wn# t
 k
 r t j j d   n X| d k r |  j |  S| d  k	 r t j j d	 |   n  |  j |  S(   Nt   substitution_valuet   [t   optst   packagess   {%s}t   sub_types5   Malformed substitution; no substitution type providedR   s'   No support for the %s substitution type(   s   optss   packages(   t	   groupdictR  Re  t   _substitute_from_other_sectiont   spanR   R  t   valuesR{   t   pathsepR   R   Rn   Ro   t   _replace_envR>   t   _replace_substitution(   R&   RB   Rv  t	   sub_valuet   startt   endR  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  $  s,    
			c         C   s   | j  d  } | s* t j j d   n  | j  d  } |  j j |  } | d  k r | d  k r t j j d | | f   n  | S| S(   NR  s*   env: requires an environment variable namet   default_valuesN   substitution env:%r: unknown environment variable %r  or recursive definition.(   t   groupR   Rn   Ro   R   R~  R>   (   R&   RB   t   envkeyR0   t   envvalue(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  E  s    		c         C   s  | j  d  r d | k r | j d  } | d | !| | d } } |  j j } | | k r | | | k r | | f |  j j k r t d | | f |  j j f   n  t | | |  } |  j j | d | d | d |  j Sn  t	 j
 j d |   d  S(	   NR  t   ]i   s   %s already in %sR-   Rz  R  s   substitution key %r not found(   Re  t   findR   R4  R{  R7  R   R   R  R   Rn   Ro   (   R&   Rn  t   iRR  t   itemt   cfgR   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  W  s    	c         C   sm   | j  d  } |  j j j | d   } | d  k rE |  j |  } n  t j j |  rc |   } n  t	 |  S(   NR  (
   R  R   RG  R   R>   R  R   R   t   callableR   (   R&   RB   t   sub_keyR   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  g  s    (   R;   R<   RA   t   compilet   VERBOSER  R#   R'   R  R  R  R  R  (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s   		!		R  c           B   s&   e  Z e d     Z e d    Z RS(   c         C   s   g  } d } x | j    D] } | j   } | s7 q n  | j d  r^ | d | d  7} q n  | | 7} t |  r | j | d t } | j |  j | |   n | j |  j	 | |   d } q W| r t
 j j d | j d f   n  | S(   s=  Parse ``commands`` argvlist multiline string.

        :param str name: Key name in a section.
        :param str value: Content stored by key.

        :rtype: list[list[str]]
        :raise :class:`tox.exception.ConfigError`:
            line-continuation ends nowhere while resolving for specified section
        R   s   \R   iR  s:   line-continuation ends nowhere while resolving for [%s] %sR   (   R  t   rstript   endswitht   is_section_substitutionR   Rc   R   R  R+   t   processcommandR   Rn   Ro   Rz  (   RW   R   RI   R   t   current_commandRL  t   replaced(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  r  s(    

	c         C   sM  t  | d d  } t g  | D] } | r | ^ q  } d } x t |  j   D] } | d k sn | d k r~ | | 7} qP nD | j d  r | j d  r | r | | 7} qP q | d d !} n  d } | j |  }	 | j |	  }	 |	 j d	 d
  j d d  }	 | |	 7} | | 7} qP Wt j | d t	 }
 t	 |
 _
 d |
 _ t |
  S(   NR  R   s	   {posargs}s   []s	   {posargs:t   }i	   is   \{R  s   \}t   posix(   R]  R   t   CommandParsert   wordsRe  R  R   R   t   shlexRc   t   whitespace_splitt   escapeR   (   RW   R   t   commandR  R   t   posargs_stringt
   newcommandt   wordt   new_argt   new_wordt   shlexer(    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s,    %


		(   R;   R<   R\   R  R  (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR  q  s   #R  c           B   s0   e  Z d  e f d     YZ d   Z d   Z RS(   t   Statec           B   s   e  Z d    Z RS(   c         C   s   d |  _  d |  _ g  |  _ d  S(   NR   i    (   R  t   deptht   yield_words(   R&   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'     s    		(   R;   R<   R'   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s   c         C   s   | |  _  d  S(   N(   R  (   R&   R  (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR'     s    c            s$  t  j       f d     f d      f d   }    f d   }  f d   }  f d   } x |  j D]     t j k r  j d k r |   n  |   qy   d k r |   |   |   qy   d	 k r |   |   qy |   |   qy W j j   r   n   j S(
   Nc              s     t  j k r.  j r.  j d t  j k p   d k r\  j d k r\  j j d  p  j d k r  j r  j d d k p   t  j k o  j o  j j   d k S(   NiR  i    s   \R  R   (   R   t
   whitespaceR  R  R  RE   (    (   t   cur_chart   ps(    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   word_has_ended  s    .+c             s/     j  }  d   _  |  r+   j j |   n  d  S(   NR   (   R  R  R+   (   t	   yieldword(   R  (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   yield_this_word  s    		c              s       r    n  d  S(   N(    (    (   R  R  (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   yield_if_word_ended  s    	c              s    j    7_  d  S(   N(   R  (    (   R  R  (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt
   accumulate  s    c              s     j  d 7_  d  S(   Ni   (   R  (    (   R  (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   push_substitution  s    c              s     j  d 8_  d  S(   Ni   (   R  (    (   R  (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   pop_substitution  s    i    R  R  (	   R  R  R  R   R  R  R  RE   R  (   R&   R  R  R  R  (    (   R  R  R  R  s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s0    




(   R;   R<   t   objectR  R'   R  (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR    s   	c           C   s$   t  d   d d g D  r  d Sd  S(   Nc         s   s   |  ] } | t  j k Vq d  S(   N(   R{   R   (   R.  R   (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pys	   <genexpr>  s    t   JENKINS_URLt
   HUDSON_URLR  (   R  R>   (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyR5    s    (A   R!   R{   R  t   fnmatchR    Ru   RA   R  R   RR   R   R   t
   subprocessR   t   tox.interpretersR   R   t   tox._verlibR   R   R   t   iswin32R   R   R   R   t   tuplet   HookimplMarkert   hookimplR  R   R   R   R,   R?   R]   Rk   R>   R   R#   R   t   ActionR   R   Rv   Rx   R  RE  R   R  R   RD  RX  Rj  RW  RG   R<  R  RB   R  R6  R  R  R  R5  (    (    (    s'   /tmp/pip-build-UnxK1c/tox/tox/config.pyt   <module>   sj   	2	4:) G							^G>