summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2013-08-08 17:43:47 -0600
committerCarl Meyer <carl@oddbird.net>2013-08-08 17:43:47 -0600
commitad245c7215ca9227c75f320f9c4474103bc3c555 (patch)
tree571c0dc0f0de367d802eb49a71c8ffde05f099b9
parentec3b9608a4e2cc4f12d0d7ab76216b0b8ec12e3a (diff)
downloadtox-ad245c7215ca9227c75f320f9c4474103bc3c555.tar.gz
Avoid adding --download-cache option to non-pip custom installers.
-rw-r--r--tests/test_venv.py15
-rw-r--r--tox/_venv.py15
2 files changed, 24 insertions, 6 deletions
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 8e40467..4e0ed3b 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -585,6 +585,21 @@ def test_run_install_command(newmocksession):
assert 'PYTHONIOENCODING' in env
assert env['PYTHONIOENCODING'] == 'utf_8'
+def test_run_custom_install_command(newmocksession):
+ mocksession = newmocksession([], """
+ [testenv]
+ install_command=easy_install {opts} {packages}
+ """)
+ venv = mocksession.getenv('python')
+ venv.just_created = True
+ venv.envconfig.envdir.ensure(dir=1)
+ action = mocksession.newaction(venv, "hello")
+ venv.run_install_command(args=["whatever"], action=action)
+ l = mocksession._pcalls
+ assert len(l) == 1
+ assert 'easy_install' in l[0].args[0]
+ assert l[0].args[1:] == ['whatever']
+
def test_command_relative_issue26(newmocksession, tmpdir, monkeypatch):
mocksession = newmocksession([], """
[testenv]
diff --git a/tox/_venv.py b/tox/_venv.py
index f43b4ab..495b2a6 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -257,25 +257,28 @@ class VirtualEnv(object):
"%s" % depinfo)
self._install(deps, action=action)
- def _commoninstallopts(self, indexserver):
+ def _installopts(self, indexserver, is_pip):
l = []
if indexserver:
l += ["-i", indexserver]
- if self.envconfig.downloadcache:
+ if is_pip and self.envconfig.downloadcache:
self.envconfig.downloadcache.ensure(dir=1)
l.append("--download-cache=%s" % self.envconfig.downloadcache)
return l
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 argv[0] == "pip" and sys.platform == "win32":
- argv[0] = "pip-script.py"
+ is_pip = False
+ if argv[0] == "pip":
+ is_pip = True
+ # use pip-script on win32 to avoid the executable locking
+ if sys.platform == "win32":
+ argv[0] = "pip-script.py"
i = argv.index('{packages}')
argv[i:i+1] = args
if '{opts}' in argv:
i = argv.index('{opts}')
- argv[i:i+1] = self._commoninstallopts(indexserver)
+ argv[i:i+1] = self._installopts(indexserver, is_pip)
for x in ('PIP_RESPECT_VIRTUALENV', 'PIP_REQUIRE_VIRTUALENV'):
try:
del os.environ[x]