summaryrefslogtreecommitdiff
path: root/tox
diff options
context:
space:
mode:
Diffstat (limited to 'tox')
-rw-r--r--tox/__init__.py8
-rw-r--r--tox/_pytestplugin.py3
-rw-r--r--tox/config.py24
-rw-r--r--tox/session.py36
4 files changed, 51 insertions, 20 deletions
diff --git a/tox/__init__.py b/tox/__init__.py
index 053386b..baf651b 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '2.3.1'
+__version__ = '2.4.0.dev1'
from .hookspecs import hookspec, hookimpl # noqa
@@ -23,5 +23,11 @@ class exception:
""" a directory did not exist. """
class MissingDependency(Error):
""" a dependency could not be found or determined. """
+ class MinVersionError(Error):
+ """ the installed tox version is lower than requested minversion. """
+
+ def __init__(self, message):
+ self.message = message
+ super(exception.MinVersionError, self).__init__(message)
from tox.session import main as cmdline # noqa
diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py
index b7693fc..4dfc497 100644
--- a/tox/_pytestplugin.py
+++ b/tox/_pytestplugin.py
@@ -195,6 +195,9 @@ class Cmd:
return py.std.subprocess.Popen(argv, stdout=stdout, stderr=stderr, **kw)
def run(self, *argv):
+ if argv[0] == "tox" and sys.version_info[:2] < (2,7):
+ pytest.skip("can not run tests involving calling tox on python2.6. "
+ "(and python2.6 is about to be deprecated anyway)")
argv = [str(x) for x in argv]
assert py.path.local.sysfind(str(argv[0])), argv[0]
p1 = self.tmpdir.join("stdout")
diff --git a/tox/config.py b/tox/config.py
index 079dff3..1fd702c 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -12,6 +12,7 @@ import pluggy
import tox.interpreters
from tox import hookspecs
+from tox._verlib import NormalizedVersion
import py
@@ -180,7 +181,7 @@ class PosargsOption:
class InstallcmdOption:
name = "install_command"
type = "argv"
- default = "pip install {opts} {packages}"
+ default = "python -m pip install {opts} {packages}"
help = "install command for dependencies and package under test."
def postprocess(self, testenv_config, value):
@@ -517,6 +518,13 @@ def tox_addoption(parser):
help="install package in develop/editable mode")
parser.add_testenv_attribute_obj(InstallcmdOption())
+
+ parser.add_testenv_attribute(
+ name = "list_dependencies_command",
+ type = "argv",
+ default = "python -m pip freeze",
+ help = "list dependencies for a virtual environment")
+
parser.add_testenv_attribute_obj(DepOption())
parser.add_testenv_attribute(
@@ -664,8 +672,18 @@ class parseini:
reader.addsubstitutions(toxinidir=config.toxinidir,
homedir=config.homedir)
- config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
+ # As older versions of tox may have bugs or incompatabilities that
+ # prevent parsing of tox.ini this must be the first thing checked.
config.minversion = reader.getstring("minversion", None)
+ # Parse our compatability immediately
+ if config.minversion:
+ minversion = NormalizedVersion(self.config.minversion)
+ toxversion = NormalizedVersion(tox.__version__)
+ if toxversion < minversion:
+ raise tox.exception.MinVersionError(
+ "tox version is %s, required is at least %s" % (
+ toxversion, minversion))
+ config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
if not config.option.skip_missing_interpreters:
config.option.skip_missing_interpreters = \
@@ -1094,7 +1112,7 @@ class _ArgvlistReader:
current_command += line
if is_section_substitution(current_command):
- replaced = reader._replace(current_command)
+ replaced = reader._replace(current_command, crossonly=True)
commands.extend(cls.getargvlist(reader, replaced))
else:
commands.append(cls.processcommand(reader, current_command))
diff --git a/tox/session.py b/tox/session.py
index ffb52d6..1d51b92 100644
--- a/tox/session.py
+++ b/tox/session.py
@@ -40,6 +40,10 @@ def main(args=None):
raise SystemExit(retcode)
except KeyboardInterrupt:
raise SystemExit(2)
+ except tox.exception.MinVersionError as e:
+ r = Reporter(None)
+ r.error(e.message)
+ raise SystemExit(1)
def show_help(config):
@@ -211,7 +215,7 @@ class Action(object):
if sys.platform == "win32":
ext = os.path.splitext(str(newargs[0]))[1].lower()
if ext == '.py' and self.venv:
- newargs = [str(self.envconfig.envpython)] + newargs
+ newargs = [str(self.venv.envconfig.envpython)] + newargs
return newargs
@@ -233,6 +237,12 @@ class Reporter(object):
self._reportedlines = []
# self.cumulated_time = 0.0
+ def _get_verbosity(self):
+ if self.session:
+ return self.session.config.option.verbosity
+ else:
+ return 2
+
def logpopen(self, popen, env):
""" log information about the action.popen() created process. """
cmd = " ".join(map(str, popen.args))
@@ -252,16 +262,17 @@ class Reporter(object):
# self.cumulated_time += duration
self.verbosity2("%s finish: %s after %.2f seconds" % (
action.venvname, action.msg, duration), bold=True)
+ delattr(action, '_starttime')
def startsummary(self):
self.tw.sep("_", "summary")
def info(self, msg):
- if self.session.config.option.verbosity >= 2:
+ if self._get_verbosity() >= 2:
self.logline(msg)
def using(self, msg):
- if self.session.config.option.verbosity >= 1:
+ if self._get_verbosity() >= 1:
self.logline("using %s" % (msg,), bold=True)
def keyboard_interrupt(self):
@@ -297,15 +308,15 @@ class Reporter(object):
self.tw.line("%s" % msg, **opts)
def verbosity0(self, msg, **opts):
- if self.session.config.option.verbosity >= 0:
+ if self._get_verbosity() >= 0:
self.logline("%s" % msg, **opts)
def verbosity1(self, msg, **opts):
- if self.session.config.option.verbosity >= 1:
+ if self._get_verbosity() >= 1:
self.logline("%s" % msg, **opts)
def verbosity2(self, msg, **opts):
- if self.session.config.option.verbosity >= 2:
+ if self._get_verbosity() >= 2:
self.logline("%s" % msg, **opts)
# def log(self, msg):
@@ -359,14 +370,6 @@ class Session:
def runcommand(self):
self.report.using("tox-%s from %s" % (tox.__version__, tox.__file__))
- if self.config.minversion:
- minversion = NormalizedVersion(self.config.minversion)
- toxversion = NormalizedVersion(tox.__version__)
- if toxversion < minversion:
- self.report.error(
- "tox version is %s, required is at least %s" % (
- toxversion, minversion))
- raise SystemExit(1)
if self.config.option.showconfig:
self.showconfig()
elif self.config.option.listenvs:
@@ -534,8 +537,9 @@ class Session:
# write out version dependency information
action = self.newaction(venv, "envreport")
with action:
- pip = venv.getcommandpath("pip")
- output = venv._pcall([str(pip), "freeze"],
+ python = venv.getcommandpath("python")
+ args = venv.envconfig.list_dependencies_command
+ output = venv._pcall(args,
cwd=self.config.toxinidir,
action=action)
# the output contains a mime-header, skip it