Commits

holger krekel committed 106f0c1

redo --upgrade option to be a "--recreate" option to force recreation of virtualenvs

  • Participants
  • Parent commits b4418d8

Comments (0)

Files changed (7)

File CHANGELOG.txt

 - issue1: Add a toxbootstrap.py script for tox
 - new option: --indexserver URL to specify PyPI index server to use for
   installation, can also be set in tox.ini testenv configurations.
-- new option: -U|--upgrade to cause installation of dependencies in upgrade mode.
+- new option: -r|--recreate to cause recreation of virtualenv
 - depend on new 'pylib' distribution instead of the whole "py" package
   which also installed py.test etc. (which is contained in py)
 

File doc/config.txt

     passed to easy_install/pip for processing.  It usually can be a file,
     and URL or a package name.
 
-.. confval:: upgrade=True|False(default)
+.. confval:: recreate=True|False(default)
 
-    Install dependencies in "upgrade" mode by passing upgrade flag to install tools.
+    Always recreate virtual environment if this option is True.
 
 .. confval:: downloadcache=path
 

File doc/example/basic.txt

 This will cause both the internal pip and easy-install steps
 to use the specified servers accordingly.
 
-upgrading packages
+forcing re-creation of virtual environments
 -----------------------------------------------
 
 .. versionadded: 0.9
 
-To upgrade dependencies on tox managed environments::
+To for tox to recreate a (particular) virtual environment::
 
-    tox --upgrade -e py27
+    tox --recreate -e py27
 
-would trigger an upgrade of the existing py27 environment
-(or create it afresh if it doesn't exist).  This will usually
-go to the PyPI server and re-install packages if neccessary.
+would trigger a complete reinstallation of the existing py27 environment
+(or create it afresh if it doesn't exist).

File tests/test_config.py

         assert config.toxworkdir == tmpdir.join(".tox")
         envconfig = config.envconfigs['python']
         assert envconfig.args_are_paths
-        assert not envconfig.upgrade
+        assert not envconfig.recreate
 
     def test_defaults_distshare(self, tmpdir, newconfig):
         config = newconfig([], "")
 
 class TestParseEnv:
 
-    def test_parse_upgrade(self, newconfig):
+    def test_parse_recreate(self, newconfig):
         inisource = ""
         config = newconfig([], inisource)
-        assert not config.envconfigs['python'].upgrade
-        config = newconfig(['--upgrade'], inisource)
-        assert config.envconfigs['python'].upgrade
-        config = newconfig(['-U'], inisource)
-        assert config.envconfigs['python'].upgrade
+        assert not config.envconfigs['python'].recreate
+        config = newconfig(['--recreate'], inisource)
+        assert config.envconfigs['python'].recreate
+        config = newconfig(['-r'], inisource)
+        assert config.envconfigs['python'].recreate
         inisource = """
             [testenv:hello]
-            upgrade = True
+            recreate = True
         """
         config = newconfig([], inisource)
-        assert config.envconfigs['hello'].upgrade
+        assert config.envconfigs['hello'].recreate
 
 class TestCmdInvocation:
     def test_help(self, cmd):

File tests/test_venv.py

     assert "-i ABC" in args
     assert "dep2" in args
 
-def test_install_upgrade(newmocksession):
-    mocksession = newmocksession(['--upgrade'], """
+def test_install_recreate(newmocksession):
+    mocksession = newmocksession(['--recreate'], """
         [testenv]
         deps=xyz
     """)
     venv = mocksession.getenv('python')
-    venv.create()
-    l = mocksession._pcalls
-    assert len(l) == 1
-
-    venv.install_deps()
-    assert len(l) == 2
-    assert '-U' in l[1].args
+    venv.update()
+    mocksession.report.expect("action", "*creating virtualenv*")
+    venv.update()
+    mocksession.report.expect("action", "recreating virtualenv*")
  
 def test_install_python3(tmpdir, newmocksession):
     if not py.path.local.sysfind('python3.1'):

File tox/_config.py

     parser.add_argument("--indexserver", action="store", dest="indexserver",
         default=None, metavar="URL",
         help="indexserver for installing deps (default pypi python.org"),
-    parser.add_argument("-U", "--upgrade", action="store_true", dest="upgrade",
-        help="try to upgrade dependencies in installation step")
+    parser.add_argument("-r", "--recreate", action="store_true",
+        dest="recreate",
+        help="recreate virtual environments")
     parser.add_argument("args", nargs="*",
         help="additional arguments available to command positional substition")
     return parser
         vc.envlogdir = reader.getpath(section, "envlogdir", "{envdir}/log")
         reader.addsubstitions(envlogdir=vc.envlogdir, envtmpdir=vc.envtmpdir)
         vc.changedir = reader.getpath(section, "changedir", "{toxinidir}")
-        if config.opts.upgrade:
-            vc.upgrade = True
+        if config.opts.recreate:
+            vc.recreate = True
         else:
-            vc.upgrade = reader.getbool(section, "upgrade", False)
+            vc.recreate = reader.getbool(section, "recreate", False)
         args = config.opts.args
         if args:
             if vc.args_are_paths:

File tox/_venv.py

         report = self.session.report
         name = self.envconfig.envname
         rconfig = CreationConfig.readconfig(self.path_config)
-        if rconfig and rconfig.matches(self._getliveconfig()):
+        if not self.envconfig.recreate and rconfig and \
+            rconfig.matches(self._getliveconfig()):
             report.action("reusing existing matching virtualenv %s" %
                 (self.envconfig.envname,))
             return
         l = [] 
         if indexserver:
             l += ["-i", indexserver]
-        if self.envconfig.upgrade:
-            l += ["-U"]
         return l
 
     def easy_install(self, args, indexserver=None):