Commits

Carl Meyer committed 16f8263

Use the install_command option for all installs.

  • Participants
  • Parent commits 209de3d

Comments (0)

Files changed (4)

tests/test_config.py

         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("""

tests/test_venv.py

         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
 
     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]
             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):
         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)
         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