From ad245c7215ca9227c75f320f9c4474103bc3c555 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 8 Aug 2013 17:43:47 -0600 Subject: Avoid adding --download-cache option to non-pip custom installers. --- tests/test_venv.py | 15 +++++++++++++++ tox/_venv.py | 15 +++++++++------ 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] -- cgit v1.2.1