summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2013-08-08 17:33:47 -0600
committerCarl Meyer <carl@oddbird.net>2013-08-08 17:33:47 -0600
commitec3b9608a4e2cc4f12d0d7ab76216b0b8ec12e3a (patch)
tree96323b9362e90aad0daaafa94eff4c50117a6962
parent3295c03dca6a10082b980b77cc1ec1fa2a321624 (diff)
downloadtox-ec3b9608a4e2cc4f12d0d7ab76216b0b8ec12e3a.tar.gz
Use the install_command option for all installs.
-rw-r--r--tests/test_config.py14
-rw-r--r--tests/test_venv.py9
-rw-r--r--tox/_config.py11
-rw-r--r--tox/_venv.py25
4 files changed, 35 insertions, 24 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index cd823c6..a4c7d2f 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -463,14 +463,20 @@ class TestConfigTestEnv:
assert envconfig.changedir.basename == "abc"
assert envconfig.changedir == config.setupdir.join("abc")
- def test_install_deps_command(self, newconfig):
+ def test_install_command(self, newconfig):
config = newconfig("""
[testenv]
- install_deps_command=pip install --pre {deps}
+ install_command=pip install --pre {packages}
""")
envconfig = config.envconfigs['python']
- assert envconfig.install_deps_argv == [
- 'pip', 'install', '--pre', '{deps}']
+ assert envconfig.install_command_argv == [
+ 'pip', 'install', '--pre', '{packages}']
+
+ def test_install_command_must_contain_packages(self, newconfig):
+ py.test.raises(tox.exception.ConfigError, newconfig, """
+ [testenv]
+ install_command=pip install
+ """)
def test_simple(tmpdir, newconfig):
config = newconfig("""
diff --git a/tests/test_venv.py b/tests/test_venv.py
index badc3b8..8e40467 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -512,12 +512,11 @@ class TestVenvTest:
monkeypatch.setattr(venv, '_pcall', lambda *args, **kwargs: 0/0)
py.test.raises(ZeroDivisionError, "venv._install(list('123'))")
py.test.raises(ZeroDivisionError, "venv.test()")
- py.test.raises(ZeroDivisionError, "venv.easy_install(['qwe'])")
- py.test.raises(ZeroDivisionError, "venv.pip_install(['qwe'])")
+ py.test.raises(ZeroDivisionError, "venv.run_install_command(['qwe'])")
py.test.raises(ZeroDivisionError, "venv._pcall([1,2,3])")
monkeypatch.setenv("PIP_RESPECT_VIRTUALENV", "1")
monkeypatch.setenv("PIP_REQUIRE_VIRTUALENV", "1")
- py.test.raises(ZeroDivisionError, "venv.pip_install(['qwe'])")
+ py.test.raises(ZeroDivisionError, "venv.run_install_command(['qwe'])")
assert 'PIP_RESPECT_VIRTUALENV' not in os.environ
assert 'PIP_REQUIRE_VIRTUALENV' not in os.environ
@@ -570,13 +569,13 @@ def test_installpkg_upgrade(newmocksession, tmpdir):
assert '-U' in l[0].args
assert '--no-deps' in l[0].args
-def test_pip_install(newmocksession):
+def test_run_install_command(newmocksession):
mocksession = newmocksession([], "")
venv = mocksession.getenv('python')
venv.just_created = True
venv.envconfig.envdir.ensure(dir=1)
action = mocksession.newaction(venv, "hello")
- venv.pip_install(args=["whatever"], action=action)
+ venv.run_install_command(args=["whatever"], action=action)
l = mocksession._pcalls
assert len(l) == 1
assert 'pip' in l[0].args[0]
diff --git a/tox/_config.py b/tox/_config.py
index 2dad2e9..7ebe97e 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -331,8 +331,15 @@ class parseini:
downloadcache = reader.getdefault(section, "downloadcache")
if downloadcache:
vc.downloadcache = py.path.local(downloadcache)
- vc.install_deps_argv = reader.getargv(
- section, "install_deps_command", "pip @@@", replace=False)
+ vc.install_command_argv = reader.getargv(
+ section,
+ "install_command",
+ "pip install {opts} {packages}",
+ replace=False,
+ )
+ if '{packages}' not in vc.install_command_argv:
+ raise tox.exception.ConfigError(
+ "'install_command' must contain '{packages}' substitution")
return vc
def _getenvlist(self, reader, toxsection):
diff --git a/tox/_venv.py b/tox/_venv.py
index 0c87319..f43b4ab 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -261,27 +261,26 @@ class VirtualEnv(object):
l = []
if indexserver:
l += ["-i", indexserver]
+ if self.envconfig.downloadcache:
+ self.envconfig.downloadcache.ensure(dir=1)
+ l.append("--download-cache=%s" % self.envconfig.downloadcache)
return l
- def easy_install(self, args, indexserver=None):
- argv = ["easy_install"] + self._commoninstallopts(indexserver) + args
- self._pcall(argv, cwd=self.envconfig.envlogdir)
-
- def pip_install(self, args, indexserver=None, action=None):
- argv = ["pip", "install"] + self._commoninstallopts(indexserver)
+ def run_install_command(self, args, indexserver=None, action=None):
+ argv = self.envconfig.install_command_argv[:]
# use pip-script on win32 to avoid the executable locking
- if sys.platform == "win32":
+ if argv[0] == "pip" and sys.platform == "win32":
argv[0] = "pip-script.py"
- if self.envconfig.downloadcache:
- self.envconfig.downloadcache.ensure(dir=1)
- argv.append("--download-cache=%s" %
- self.envconfig.downloadcache)
+ i = argv.index('{packages}')
+ argv[i:i+1] = args
+ if '{opts}' in argv:
+ i = argv.index('{opts}')
+ argv[i:i+1] = self._commoninstallopts(indexserver)
for x in ('PIP_RESPECT_VIRTUALENV', 'PIP_REQUIRE_VIRTUALENV'):
try:
del os.environ[x]
except KeyError:
pass
- argv += args
env = dict(PYTHONIOENCODING='utf_8')
self._pcall(argv, cwd=self.envconfig.envlogdir, extraenv=env,
action=action)
@@ -307,7 +306,7 @@ class VirtualEnv(object):
extraopts = extraopts or []
for ixserver in l:
args = d[ixserver] + extraopts
- self.pip_install(args, ixserver.url, action)
+ self.run_install_command(args, ixserver.url, action)
def _getenv(self):
env = self.envconfig.setenv