diff options
author | Holger Krekel <holger@merlinux.eu> | 2016-06-20 16:45:10 +0200 |
---|---|---|
committer | Holger Krekel <holger@merlinux.eu> | 2016-06-20 16:45:10 +0200 |
commit | df580330eaa1bbce79012f8cfaa5c4d0a5ddf93d (patch) | |
tree | cbd181d68c9e4bc52865a7475ba52023d48f8d2c | |
parent | 1d9b5284bdc1d3a6f1cd67ef82e8b882299e5683 (diff) | |
parent | 2c81964af2372e7e82913dd88b2e0d66fb42c343 (diff) | |
download | tox-df580330eaa1bbce79012f8cfaa5c4d0a5ddf93d.tar.gz |
Merged in bittner/tox/bittner/remove-invalid-return-value-in-toxcmdlin-1465935081972 (pull request #196)
Remove invalid return value in tox.cmdline() example
-rw-r--r-- | CHANGELOG | 109 | ||||
-rwxr-xr-x | doc/_getdoctarget.py | 2 | ||||
-rw-r--r-- | doc/config.txt | 15 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/test_config.py | 20 | ||||
-rw-r--r-- | tests/test_interpreters.py | 2 | ||||
-rw-r--r-- | tests/test_venv.py | 12 | ||||
-rw-r--r-- | tox.ini | 7 | ||||
-rw-r--r-- | tox/__init__.py | 8 | ||||
-rw-r--r-- | tox/_pytestplugin.py | 9 | ||||
-rw-r--r-- | tox/_quickstart.py | 2 | ||||
-rw-r--r-- | tox/config.py | 22 | ||||
-rw-r--r-- | tox/interpreters.py | 6 | ||||
-rw-r--r-- | tox/result.py | 6 | ||||
-rw-r--r-- | tox/session.py | 34 |
15 files changed, 169 insertions, 87 deletions
@@ -1,3 +1,18 @@ +2.4.0 +----- + +- introduce per-venv list_dependencies_command which defaults + to "python -m pip freeze" to obtain the list of installed packages. + If you need to run python2.6 you need to configure it to + something like "pip freeze". Thanks Ted Shaw, Holger Krekel. + +- fix issue66, issue121: change install_command to use "python -m pip" + by default instead of "pip ..." directly which avoids long shebang + issues. If you need to run python2.6 you need to configure it to + something like "pip install {opts} {packages}". Thanks Ted Shaw, + Holger Krekel. + + 2.3.2 ----- @@ -6,6 +21,8 @@ - fix issue279: allow cross-section substitution when the value contains posargs. Thanks Sachi King for the PR. +- fix issue317: evaluate minversion before tox config is parsed completely. + Thanks Sachi King for the PR. 2.3.1 ----- @@ -20,8 +37,8 @@ devpi system for managing indexes for pip. - fix issue285: make setenv processing fully lazy to fix regressions - of tox-2.2.X and so that we can now have testenv attributes like - "basepython" depend on environment variables that are set in + of tox-2.2.X and so that we can now have testenv attributes like + "basepython" depend on environment variables that are set in a setenv section. Thanks Nelfin for some tests and initial work on a PR. @@ -34,11 +51,11 @@ - fix issue252: allow environment names with special characters. Thanks Julien Castets for initial PR and patience. -- introduce experimental tox_testenv_create(venv, action) and +- introduce experimental tox_testenv_create(venv, action) and tox_testenv_install_deps(venv, action) hooks to allow plugins to do additional work on creation or installing deps. These hooks are experimental mainly because of - the involved "venv" and session objects whose current public + the involved "venv" and session objects whose current public API is not fully guranteed. - internal: push some optional object creation into tests because @@ -57,18 +74,18 @@ because otherwise the python interpreter might not start up in certain configurations (redhat software collections). Thanks David Riddle. -- fix issue246: fix regression in config parsing by reordering +- fix issue246: fix regression in config parsing by reordering such that {envbindir} can be used again in tox.ini. Thanks Olli Walsh. - fix issue99: the {env:...} substitution now properly uses environment settings from the ``setenv`` section. Thanks Itxaka Serrano. -- fix issue281: make --force-deps work when urls are present in +- fix issue281: make --force-dep work when urls are present in dependency configs. Thanks Glyph Lefkowitz for reporting. - fix issue174: add new ``ignore_outcome`` testenv attribute which can be set to True in which case it will produce a warning instead - of an error on a failed testenv command outcome. + of an error on a failed testenv command outcome. Thanks Rebecka Gulliksson for the PR. - fix issue280: properly skip missing interpreter if @@ -85,7 +102,7 @@ 2.1.0 ---------- -- fix issue258, fix issue248, fix issue253: for non-test commands +- fix issue258, fix issue248, fix issue253: for non-test commands (installation, venv creation) we pass in the full invocation environment. - remove experimental --set-home option which was hardly used and @@ -106,7 +123,7 @@ 2.0.2 ---------- -- fix issue247: tox now passes the LANG variable from the tox invocation +- fix issue247: tox now passes the LANG variable from the tox invocation environment to the test environment by default. - add SYSTEMDRIVE into default passenv on windows to allow pip6 to work. @@ -123,9 +140,9 @@ - (new) introduce environment variable isolation: tox now only passes the PATH and PIP_INDEX_URL variable from the tox - invocation environment to the test environment and on Windows + invocation environment to the test environment and on Windows also ``SYSTEMROOT``, ``PATHEXT``, ``TEMP`` and ``TMP`` whereas - on unix additionally ``TMPDIR`` is passed. If you need to pass + on unix additionally ``TMPDIR`` is passed. If you need to pass through further environment variables you can use the new ``passenv`` setting, a space-separated list of environment variable names. Each name can make use of fnmatch-style glob patterns. All environment @@ -136,9 +153,9 @@ their defaults. - (new) introduce a way to specify on which platform a testenvironment is to - execute: the new per-venv "platform" setting allows to specify + execute: the new per-venv "platform" setting allows to specify a regular expression which is matched against sys.platform. - If platform is set and doesn't match the platform spec in the test + If platform is set and doesn't match the platform spec in the test environment the test environment is ignored, no setup or tests are attempted. - (new) add per-venv "ignore_errors" setting, which defaults to False. @@ -169,7 +186,7 @@ See tox/hookspecs.py for the current hooks. - introduce parser.add_testenv_attribute() to register an ini-variable - for testenv sections. Can be used from plugins through the + for testenv sections. Can be used from plugins through the tox_add_option hook. - rename internal files -- tox offers no external API except for the @@ -182,7 +199,7 @@ 1.9.2 ----------- -- backout ability that --force-deps substitutes name/versions in +- backout ability that --force-dep substitutes name/versions in requirement files due to various issues. This fixes issue228, fixes issue230, fixes issue231 which popped up with 1.9.1. @@ -193,7 +210,7 @@ - use a file instead of a pipe for command output in "--result-json". Fixes some termination issues with python2.6. -- allow --force-deps to override dependencies in "-r" requirements +- allow --force-dep to override dependencies in "-r" requirements files. Thanks Sontek for the PR. - fix issue227: use "-m virtualenv" instead of "-mvirtualenv" to make @@ -208,7 +225,7 @@ dependencies. Use ``pip_pre = true`` in a testenv or the ``--pre`` command-line option to restore the previous behavior. -- fix issue199: fill resultlog structure ahead of virtualenv creation +- fix issue199: fill resultlog structure ahead of virtualenv creation - refine determination if we run from Jenkins, thanks Borge Lanes. @@ -266,7 +283,7 @@ - fix issue59: add a config variable ``skip-missing-interpreters`` as well as command line option ``--skip-missing-interpreters`` which won't fail the - build if Python interpreters listed in tox.ini are missing. Thanks + build if Python interpreters listed in tox.ini are missing. Thanks Alexandre Conrad for PR104. - fix issue164: better traceback info in case of failing test commands. @@ -284,29 +301,29 @@ - fix issue162: don't list python 2.5 as compatibiliy/supported - fix issue158 and fix issue155: windows/virtualenv properly works now: - call virtualenv through "python -m virtualenv" with the same + call virtualenv through "python -m virtualenv" with the same interpreter which invoked tox. Thanks Chris Withers, Ionel Maries Cristian. 1.7.0 --------- -- don't lookup "pip-script" anymore but rather just "pip" on windows - as this is a pip implementation detail and changed with pip-1.5. - It might mean that tox-1.7 is not able to install a different pip +- don't lookup "pip-script" anymore but rather just "pip" on windows + as this is a pip implementation detail and changed with pip-1.5. + It might mean that tox-1.7 is not able to install a different pip version into a virtualenv anymore. - drop Python2.5 compatibility because it became too hard due - to the setuptools-2.0 dropping support. tox now has no + to the setuptools-2.0 dropping support. tox now has no support for creating python2.5 based environments anymore and all internal special-handling has been removed. -- merged PR81: new option --force-dep which allows to +- merged PR81: new option --force-dep which allows to override tox.ini specified dependencies in setuptools-style. For example "--force-dep 'django<1.6'" will make sure - that any environment using "django" as a dependency will - get the latest 1.5 release. Thanks Bruno Oliveria for + that any environment using "django" as a dependency will + get the latest 1.5 release. Thanks Bruno Oliveria for the complete PR. - + - merged PR125: tox now sets "PYTHONHASHSEED" to a random value and offers a "--hashseed" option to repeat a test run with a specific seed. You can also use --hashsheed=noset to instruct tox to leave the value @@ -324,9 +341,9 @@ - fix issue130: you can now set install_command=easy_install {opts} {packages} and expect it to work for repeated tox runs (previously it only worked - when always recreating). Thanks jenisys for precise reporting. + when always recreating). Thanks jenisys for precise reporting. -- fix issue129: tox now uses Popen(..., universal_newlines=True) to force +- fix issue129: tox now uses Popen(..., universal_newlines=True) to force creation of unicode stdout/stderr streams. fixes a problem on specific platform configs when creating virtualenvs with Python3.3. Thanks Jorgen Schäfer or investigation and solution sketch. @@ -344,7 +361,7 @@ requiring networks - introduce --sitepackages to force sitepackages=True in all - environments. + environments. - fix issue105 -- don't depend on an existing HOME directory from tox tests. @@ -354,8 +371,8 @@ - fix issue119: {envsitepackagesdir} is now correctly computed and has a better test to prevent regression. -- fix issue116: make 1.6 introduced behaviour of changing to a - per-env HOME directory during install activities dependent +- fix issue116: make 1.6 introduced behaviour of changing to a + per-env HOME directory during install activities dependent on "--set-home" for now. Should re-establish the old behaviour when no option is given. @@ -365,9 +382,9 @@ - fix test runs on environments without a home directory (in this case we use toxinidir as the homedir) -- fix issue117: python2.5 fix: don't use ``--insecure`` option because +- fix issue117: python2.5 fix: don't use ``--insecure`` option because its very existence depends on presence of "ssl". If you - want to support python2.5/pip1.3.1 based test environments you need + want to support python2.5/pip1.3.1 based test environments you need to install ssl and/or use PIP_INSECURE=1 through ``setenv``. section. - fix issue102: change to {toxinidir} when installing dependencies. @@ -380,11 +397,11 @@ configure the installation command with options for dep/pkg install. Thanks Carl Meyer for the PR and docs. -- fix issue91: python2.5 support by vendoring the virtualenv-1.9.1 - script and forcing pip<1.4. Also the default [py25] environment +- fix issue91: python2.5 support by vendoring the virtualenv-1.9.1 + script and forcing pip<1.4. Also the default [py25] environment modifies the default installer_command (new config option) - to use pip without the "--pre" option which was introduced - with pip-1.4 and is now required if you want to install non-stable + to use pip without the "--pre" option which was introduced + with pip-1.4 and is now required if you want to install non-stable releases. (tox defaults to install with "--pre" everywhere). - during installation of dependencies HOME is now set to a pseudo @@ -421,7 +438,7 @@ - fix issue104: use setuptools by default, instead of distribute, now that setuptools has distribute merged. -- make sure test commands are searched first in the virtualenv +- make sure test commands are searched first in the virtualenv - re-fix issue2 - add whitelist_externals to be used in ``[testenv*]`` sections, allowing to avoid warnings for commands such as ``make``, @@ -432,12 +449,12 @@ - fix issue92 - fix {envsitepackagesdir} to actually work again -- show (test) command that is being executed, thanks +- show (test) command that is being executed, thanks Lukasz Balcerzak - re-license tox to MIT license -- depend on virtualenv-1.9.1 +- depend on virtualenv-1.9.1 - rename README.txt to README.rst to make bitbucket happier @@ -452,7 +469,7 @@ (thanks Lukasz Balcerzak) - fix downloadcache determination to work according to docs: Only - make pip use a download cache if PIP_DOWNLOAD_CACHE or a + make pip use a download cache if PIP_DOWNLOAD_CACHE or a downloadcache=PATH testenv setting is present. (The ENV setting takes precedence) @@ -476,7 +493,7 @@ - fix #48 - win32 detection of pypy and other interpreters that are on PATH (thanks Gustavo Picon) -- fix grouping of index servers, it is now done by name instead of +- fix grouping of index servers, it is now done by name instead of indexserver url, allowing to use it to separate dependencies into groups even if using the same default indexserver. @@ -512,7 +529,7 @@ which would formerly raise irritating errors because the ";" was considered a comment - tweak and improve reporting -- refactor reporting and virtualenv manipulation +- refactor reporting and virtualenv manipulation to be more accessible from 3rd party tools - support value substitution from other sections with the {[section]key} syntax @@ -527,8 +544,8 @@ 1.3 ----------------- -- fix: allow to specify wildcard filesystem paths when - specifying dependencies such that tox searches for +- fix: allow to specify wildcard filesystem paths when + specifying dependencies such that tox searches for the highest version - fix issue issue21: clear PIP_REQUIRES_VIRTUALENV which avoids diff --git a/doc/_getdoctarget.py b/doc/_getdoctarget.py index 1199221..f92e87b 100755 --- a/doc/_getdoctarget.py +++ b/doc/_getdoctarget.py @@ -13,4 +13,4 @@ def get_minor_version_string(): return ".".join(get_version_string().split(".")[:2]) if __name__ == "__main__": - print (get_minor_version_string()) + print(get_minor_version_string()) diff --git a/doc/config.txt b/doc/config.txt index 205b22a..229f357 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -105,7 +105,20 @@ Complete list of settings that you can put into ``testenv*`` sections: **default**:: - pip install {opts} {packages} + python -m pip install {opts} {packages} + + +.. confval:: list_dependencies_command + + .. versionadded:: 2.4 + + the ``list_dependencies_command`` setting is used for listing + the packages installed into the virtual environment. + + **default**:: + + python -m pip freeze + .. confval:: ignore_errors=True|False(default) @@ -48,7 +48,7 @@ def main(): description='virtualenv-based automation of test activities', long_description=open("README.rst").read(), url='http://tox.testrun.org/', - version='2.3.2', + version='2.4.0.dev1', license='http://opensource.org/licenses/MIT', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel', diff --git a/tests/test_config.py b/tests/test_config.py index 372cd4f..ffc8343 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -288,6 +288,20 @@ class TestIniParserAgainstCommandsKey: x = reader.getargvlist("commands") assert x == [['thing', 'argpos', 'arg2']] + def test_command_section_and_posargs_substitution(self, newconfig): + """Ensure subsitition from other section with posargs succeeds""" + config = newconfig(""" + [section] + key = thing arg1 + [testenv] + commands = + {[section]key} {posargs} endarg + """) + reader = SectionReader("testenv", config._cfg) + reader.addsubstitutions([r"argpos"]) + x = reader.getargvlist("commands") + assert x == [['thing', 'arg1', 'argpos', 'endarg']] + def test_command_env_substitution(self, newconfig): """Ensure referenced {env:key:default} values are substituted correctly.""" config = newconfig(""" @@ -1424,10 +1438,10 @@ class TestGlobalOptions: def test_minversion(self, tmpdir, newconfig, monkeypatch): inisource = """ [tox] - minversion = 3.0 + minversion = 10.0 """ - config = newconfig([], inisource) - assert config.minversion == "3.0" + with py.test.raises(tox.exception.MinVersionError): + config = newconfig([], inisource) def test_skip_missing_interpreters_true(self, tmpdir, newconfig, monkeypatch): inisource = """ diff --git a/tests/test_interpreters.py b/tests/test_interpreters.py index d2cfa27..c658380 100644 --- a/tests/test_interpreters.py +++ b/tests/test_interpreters.py @@ -41,7 +41,7 @@ def test_tox_get_python_executable(): if sys.platform == "win32": pydir = "python%s" % ver.replace(".", "") x = py.path.local("c:\%s" % pydir) - print (x) + print(x) if not x.check(): continue else: diff --git a/tests/test_venv.py b/tests/test_venv.py index 4ab3b06..30bdf3c 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -137,8 +137,8 @@ def test_install_deps_wildcard(newmocksession): assert len(l) == 2 args = l[-1].args assert l[-1].cwd == venv.envconfig.config.toxinidir - assert "pip" in str(args[0]) - assert args[1] == "install" + assert "pip" in str(args[2]) + assert args[3] == "install" # arg = "--download-cache=" + str(venv.envconfig.downloadcache) # assert arg in args[2:] args = [arg for arg in args if str(arg).endswith("dep1-1.1.zip")] @@ -167,8 +167,8 @@ def test_install_downloadcache(newmocksession, monkeypatch, tmpdir, envdc): assert len(l) == 2 args = l[-1].args assert l[-1].cwd == venv.envconfig.config.toxinidir - assert "pip" in str(args[0]) - assert args[1] == "install" + assert "pip" in str(args) + assert args[3] == "install" assert "dep1" in args assert "dep2" in args deps = list(filter(None, [x[1] for x in venv._getliveconfig().deps])) @@ -365,7 +365,7 @@ def test_install_python3(tmpdir, newmocksession): venv._install(["hello"], action=action) assert len(l) == 1 args = l[0].args - assert 'pip' in str(args[0]) + assert "pip" in [str(x) for x in args] for x in args: assert "--download-cache" not in args, args @@ -597,7 +597,7 @@ def test_run_install_command(newmocksession): venv.run_install_command(packages=["whatever"], action=action) l = mocksession._pcalls assert len(l) == 1 - assert 'pip' in l[0].args[0] + assert 'pip' in l[0].args[2] assert 'install' in l[0].args env = l[0].env assert env is not None @@ -13,6 +13,13 @@ deps=pytest>=2.3.5 [testenv:py26-bare] deps = commands = tox -h +install_command = pip install {opts} {packages} +list_dependencies_command = pip freeze + +[testenv:py26] +install_command = pip install {opts} {packages} +list_dependencies_command = pip freeze + [testenv:docs] basepython=python diff --git a/tox/__init__.py b/tox/__init__.py index c17341d..baf651b 100644 --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '2.3.2' +__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 f15d2ec..4dfc497 100644 --- a/tox/_pytestplugin.py +++ b/tox/_pytestplugin.py @@ -68,12 +68,12 @@ class ReportExpectMock: def generic_report(*args, **kwargs): self._calls.append((name,) + args) - print ("%s" % (self._calls[-1], )) + print("%s" % (self._calls[-1], )) return generic_report def action(self, venv, msg, *args): self._calls.append(("action", venv, msg)) - print ("%s" % (self._calls[-1], )) + print("%s" % (self._calls[-1], )) return Action(self.session, venv, msg, args) def getnext(self, cat): @@ -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") @@ -316,7 +319,7 @@ def initproj(request, tmpdir): for p in base.visit(lambda x: x.check(file=1)): manifestlines.append("include %s" % p.relto(base)) create_files(base, {"MANIFEST.in": "\n".join(manifestlines)}) - print ("created project in %s" % (base,)) + print("created project in %s" % (base,)) base.chdir() return initproj diff --git a/tox/_quickstart.py b/tox/_quickstart.py index a397cb1..59ee48e 100644 --- a/tox/_quickstart.py +++ b/tox/_quickstart.py @@ -119,7 +119,7 @@ def do_prompt(d, key, text, default=None, validator=nonempty): x = term_input(prompt) if default and not x: x = default - if sys.version_info < (3, ) and not isinstance(x, unicode): + if sys.version_info < (3, ) and not isinstance(x, unicode): # noqa # for Python 2.x, try to get a Unicode string out of it if x.decode('ascii', 'replace').encode('ascii', 'replace') != x: if TERM_ENCODING: diff --git a/tox/config.py b/tox/config.py index 67454bc..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 = \ diff --git a/tox/interpreters.py b/tox/interpreters.py index 66e6409..e049f1d 100644 --- a/tox/interpreters.py +++ b/tox/interpreters.py @@ -43,10 +43,10 @@ class Interpreters: try: res = exec_on_interpreter(info.executable, [inspect.getsource(sitepackagesdir), - "print (sitepackagesdir(%r))" % envdir]) + "print(sitepackagesdir(%r))" % envdir]) except ExecFailed: val = sys.exc_info()[1] - print ("execution failed: %s -- %s" % (val.out, val.err)) + print("execution failed: %s -- %s" % (val.out, val.err)) return "" else: return res["dir"] @@ -56,7 +56,7 @@ def run_and_get_interpreter_info(name, executable): assert executable try: result = exec_on_interpreter(executable, - [inspect.getsource(pyinfo), "print (pyinfo())"]) + [inspect.getsource(pyinfo), "print(pyinfo())"]) except ExecFailed: val = sys.exc_info()[1] return NoInterpreterInfo(name, executable=val.executable, diff --git a/tox/result.py b/tox/result.py index 96ac612..bad8cc3 100644 --- a/tox/result.py +++ b/tox/result.py @@ -47,9 +47,9 @@ class EnvLog: pythonexecutable = py.path.local(pythonexecutable) out = pythonexecutable.sysexec("-c", "import sys; " - "print (sys.executable);" - "print (list(sys.version_info)); " - "print (sys.version)") + "print(sys.executable);" + "print(list(sys.version_info)); " + "print(sys.version)") lines = out.splitlines() executable = lines.pop(0) version_info = eval(lines.pop(0)) diff --git a/tox/session.py b/tox/session.py index 93ef5d8..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): @@ -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 |