From 838d35ad0b707ebe5dc6a3ee7c20be737501a6ed Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 24 Oct 2013 09:38:45 +0200 Subject: fix issue130: you can now set install_command=easy_install {opts} {packages} and expect it to run without the need to recreate. Thanks jenisys for precise reporting. --- CHANGELOG | 4 ++++ tests/test_venv.py | 10 ++++++---- tox/_venv.py | 17 ++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3bff145..14889c2 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ 1.6.2.dev --------- +- fix issue130: you can now set install_command=easy_install {opts} {packages} + and expect it to run without the need to recreate. Thanks jenisys for + precise reporting. + - fix issue129: tox now uses Popen(..., universal_newlines=True) to force creation of unicode stdout/stderr streams. fixes a problem on specific platform configs when creating virtualenvs with Python3.3. Thanks Jorgen Schäfer diff --git a/tests/test_venv.py b/tests/test_venv.py index 67bdb92..801f02a 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -520,8 +520,10 @@ def test_installpkg_upgrade(newmocksession, tmpdir): mocksession.installpkg(venv, pkg) l = mocksession._pcalls assert len(l) == 1 - assert '-U' in l[0].args - assert '--no-deps' in l[0].args + index = l[0].args.index(str(pkg)) + assert index >= 0 + assert '-U' in l[0].args[:index] + assert '--no-deps' in l[0].args[:index] def test_run_install_command(newmocksession): mocksession = newmocksession([], "") @@ -529,7 +531,7 @@ def test_run_install_command(newmocksession): venv.just_created = True venv.envconfig.envdir.ensure(dir=1) action = mocksession.newaction(venv, "hello") - venv.run_install_command(args=["whatever"], action=action) + venv.run_install_command(packages=["whatever"], action=action) l = mocksession._pcalls assert len(l) == 1 assert 'pip' in l[0].args[0] @@ -548,7 +550,7 @@ def test_run_custom_install_command(newmocksession): venv.just_created = True venv.envconfig.envdir.ensure(dir=1) action = mocksession.newaction(venv, "hello") - venv.run_install_command(args=["whatever"], action=action) + venv.run_install_command(packages=["whatever"], action=action) l = mocksession._pcalls assert len(l) == 1 assert 'easy_install' in l[0].args[0] diff --git a/tox/_venv.py b/tox/_venv.py index cb53ec0..de7f443 100644 --- a/tox/_venv.py +++ b/tox/_venv.py @@ -280,17 +280,18 @@ class VirtualEnv(object): l.append("--download-cache=%s" % self.envconfig.downloadcache) return l - def run_install_command(self, args, indexserver=None, action=None, + def run_install_command(self, packages, options=(), + indexserver=None, action=None, extraenv=None): argv = self.envconfig.install_command[:] # use pip-script on win32 to avoid the executable locking if argv[0] == "pip" and sys.platform == "win32": argv[0] = "pip-script.py" i = argv.index('{packages}') - argv[i:i+1] = args + argv[i:i+1] = packages if '{opts}' in argv: i = argv.index('{opts}') - argv[i:i+1] = self._installopts(indexserver) + argv[i:i+1] = list(options) for x in ('PIP_RESPECT_VIRTUALENV', 'PIP_REQUIRE_VIRTUALENV'): try: del os.environ[x] @@ -320,7 +321,6 @@ class VirtualEnv(object): l.append(ixserver) assert ixserver.url is None or isinstance(ixserver.url, str) - extraopts = extraopts or [] for ixserver in l: if self.envconfig.config.option.sethome: extraenv = hack_home_env( @@ -329,9 +329,12 @@ class VirtualEnv(object): else: extraenv = {} - args = d[ixserver] + extraopts - self.run_install_command(args, ixserver.url, action, - extraenv=extraenv) + packages = d[ixserver] + options = self._installopts(ixserver.url) + if extraopts: + options.extend(extraopts) + self.run_install_command(packages=packages, options=options, + action=action, extraenv=extraenv) def _getenv(self): env = self.envconfig.setenv -- cgit v1.2.1