diff options
-rw-r--r-- | CHANGELOG | 9 | ||||
-rw-r--r-- | doc/config.txt | 17 | ||||
-rw-r--r-- | tests/test_config.py | 19 | ||||
-rw-r--r-- | tests/test_venv.py | 19 | ||||
-rw-r--r-- | tox/_config.py | 9 | ||||
-rw-r--r-- | tox/_venv.py | 2 |
6 files changed, 72 insertions, 3 deletions
@@ -1,3 +1,12 @@ +1.9.0.dev +----------- + +- fix issue193: Remove ``--pre`` from the default ``install_command``; by + default tox will now only install final releases from PyPI for unpinned + dependencies. Use ``pip_pre = true`` in a testenv or the ``--pre`` + command-line option to restore the previous behavior. + + 1.8.1.dev ----------- diff --git a/doc/config.txt b/doc/config.txt index 8ce64db..2fba5f7 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -106,7 +106,22 @@ Complete list of settings that you can put into ``testenv*`` sections: **default**:: - pip install --pre {opts} {packages} + pip install {opts} {packages} + +.. confval:: pip_pre=True|False(default) + + .. versionadded:: 1.9 + + If ``True``, adds ``--pre`` to the ``opts`` passed to + :confval:`install_command`. If :confval:`install_command` uses pip, this + will cause it to install the latest available pre-release of any + dependencies without a specified version. If ``False`` (the default), pip + will only install final releases of unpinned dependencies. + + Passing the ``--pre`` command-line option to tox will force this to + ``True`` for all testenvs. + + Don't set this option if your :confval:`install_command` does not use pip. .. confval:: whitelist_externals=MULTI-LINE-LIST diff --git a/tests/test_config.py b/tests/test_config.py index c823cb3..18ad222 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -106,6 +106,7 @@ class TestConfigPackage: envconfig = config.envconfigs['python'] assert envconfig.args_are_paths assert not envconfig.recreate + assert not envconfig.pip_pre def test_defaults_distshare(self, tmpdir, newconfig): config = newconfig([], "") @@ -620,6 +621,24 @@ class TestConfigTestEnv: 'some_install', '--arg=%s/foo' % config.toxinidir, 'python', '{opts}', '{packages}'] + def test_pip_pre(self, newconfig): + config = newconfig(""" + [testenv] + pip_pre=true + """) + envconfig = config.envconfigs['python'] + assert envconfig.pip_pre + + def test_pip_pre_cmdline_override(self, newconfig): + config = newconfig( + ['--pre'], + """ + [testenv] + pip_pre=false + """) + envconfig = config.envconfigs['python'] + assert envconfig.pip_pre + def test_downloadcache(self, newconfig, monkeypatch): monkeypatch.delenv("PIP_DOWNLOAD_CACHE", raising=False) config = newconfig(""" diff --git a/tests/test_venv.py b/tests/test_venv.py index b1d1f2e..942888f 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -211,6 +211,25 @@ def test_install_deps_indexserver(newmocksession): assert "-i ABC" in args assert "dep3" in args +def test_install_deps_pre(newmocksession): + mocksession = newmocksession([], """ + [testenv] + pip_pre=true + deps= + dep1 + """) + venv = mocksession.getenv('python') + venv.create() + l = mocksession._pcalls + assert len(l) == 1 + l[:] = [] + + venv.install_deps() + assert len(l) == 1 + args = " ".join(l[0].args) + assert "--pre " in args + assert "dep1" in args + def test_installpkg_indexserver(newmocksession, tmpdir): mocksession = newmocksession([], """ [tox] diff --git a/tox/_config.py b/tox/_config.py index f0ad87e..ceae6b9 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -105,6 +105,9 @@ def prepare_parse(pkgname): dest="indexurl", metavar="URL", help="set indexserver url (if URL is of form name=url set the " "url for the 'name' indexserver, specifically)") + parser.add_argument("--pre", action="store_true", dest="pre", + help="install pre-releases and development versions of dependencies. " + "This will pass the --pre option to install_command (pip by default).") parser.add_argument("-r", "--recreate", action="store_true", dest="recreate", help="force recreation of virtual environments") @@ -381,15 +384,17 @@ class parseini: downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", downloadcache) vc.downloadcache = py.path.local(downloadcache) - pip_default_opts = ["--pre", "{opts}", "{packages}"] vc.install_command = reader.getargv( section, "install_command", - "pip install " + " ".join(pip_default_opts), + "pip install {opts} {packages}", ) if '{packages}' not in vc.install_command: raise tox.exception.ConfigError( "'install_command' must contain '{packages}' substitution") + vc.pip_pre = config.option.pre or reader.getbool( + section, "pip_pre", False) + return vc def _getenvdata(self, reader, toxsection): diff --git a/tox/_venv.py b/tox/_venv.py index 0c56cc0..937a881 100644 --- a/tox/_venv.py +++ b/tox/_venv.py @@ -260,6 +260,8 @@ class VirtualEnv(object): if self.envconfig.downloadcache: self.envconfig.downloadcache.ensure(dir=1) l.append("--download-cache=%s" % self.envconfig.downloadcache) + if self.envconfig.pip_pre: + l.append("--pre") return l def run_install_command(self, packages, options=(), |