summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2014-10-06 17:36:05 -0600
committerCarl Meyer <carl@oddbird.net>2014-10-06 17:36:05 -0600
commitfde8f18e5baa7c4bad05be63847d2bb4ac971248 (patch)
treeed3a0c27149ac46eb26b0422cc1525a1c4a89c57
parente6c99fa4b0a2056009b69144e3a8ed908e2ac053 (diff)
downloadtox-fde8f18e5baa7c4bad05be63847d2bb4ac971248.tar.gz
Add --pre and testenv pip_pre options, no --pre by default.
-rw-r--r--CHANGELOG9
-rw-r--r--doc/config.txt17
-rw-r--r--tests/test_config.py19
-rw-r--r--tests/test_venv.py19
-rw-r--r--tox/_config.py8
-rw-r--r--tox/_venv.py2
6 files changed, 71 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3e73166..711f93e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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 bf74133..79e9a74 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 3c1b8c2..a778b11 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -105,6 +105,8 @@ 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="pass --pre option to install_command")
parser.add_argument("-r", "--recreate", action="store_true",
dest="recreate",
help="force recreation of virtual environments")
@@ -381,15 +383,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=(),