9 new commits in tox:

https://bitbucket.org/hpk42/tox/commits/4cdc267e9f82/
Changeset:   4cdc267e9f82
User:        carljm
Date:        2013-08-09 00:46:24
Summary:     Add install_deps_command testenv option.
Affected #:  2 files

diff -r 3be5bca16f8b0c4394060b8e0377ef1883c518c7 -r 
4cdc267e9f8290a19945c45d962a85f3d4f7d5f1 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -463,6 +463,14 @@
         assert envconfig.changedir.basename == "abc"
         assert envconfig.changedir == config.setupdir.join("abc")
 
+    def test_install_deps_command(self, newconfig):
+        config = newconfig("""
+            [testenv]
+            install_deps_command=pip install --pre {deps}
+        """)
+        envconfig = config.envconfigs['python']
+        assert envconfig.install_deps_command == "pip install --pre {deps}"
+
     def test_simple(tmpdir, newconfig):
         config = newconfig("""
             [testenv:py24]

diff -r 3be5bca16f8b0c4394060b8e0377ef1883c518c7 -r 
4cdc267e9f8290a19945c45d962a85f3d4f7d5f1 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -331,6 +331,8 @@
             downloadcache = reader.getdefault(section, "downloadcache")
         if downloadcache:
             vc.downloadcache = py.path.local(downloadcache)
+        vc.install_deps_command = reader.getdefault(
+            section, "install_deps_command", "pip @@@", replace=False)
         return vc
 
     def _getenvlist(self, reader, toxsection):


https://bitbucket.org/hpk42/tox/commits/209de3d6baba/
Changeset:   209de3d6baba
User:        carljm
Date:        2013-08-09 00:59:12
Summary:     Config parser shlex-splits install_deps_command.
Affected #:  2 files

diff -r 4cdc267e9f8290a19945c45d962a85f3d4f7d5f1 -r 
209de3d6bababd1af01fe0ae8d2488fb0d3d4198 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -469,7 +469,8 @@
             install_deps_command=pip install --pre {deps}
         """)
         envconfig = config.envconfigs['python']
-        assert envconfig.install_deps_command == "pip install --pre {deps}"
+        assert envconfig.install_deps_argv == [
+            'pip', 'install', '--pre', '{deps}']
 
     def test_simple(tmpdir, newconfig):
         config = newconfig("""

diff -r 4cdc267e9f8290a19945c45d962a85f3d4f7d5f1 -r 
209de3d6bababd1af01fe0ae8d2488fb0d3d4198 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -331,7 +331,7 @@
             downloadcache = reader.getdefault(section, "downloadcache")
         if downloadcache:
             vc.downloadcache = py.path.local(downloadcache)
-        vc.install_deps_command = reader.getdefault(
+        vc.install_deps_argv = reader.getargv(
             section, "install_deps_command", "pip @@@", replace=False)
         return vc
 
@@ -471,6 +471,12 @@
 
         return shlex.split(new_command.strip())
 
+    def getargv(self, section, name, default=None, replace=True):
+        command = self.getdefault(
+            section, name, default=default, replace=replace)
+
+        return shlex.split(command.strip())
+
     def getbool(self, section, name, default=None):
         s = self.getdefault(section, name, default)
         if s is None:


https://bitbucket.org/hpk42/tox/commits/16f82639efc6/
Changeset:   16f82639efc6
User:        carljm
Date:        2013-08-09 01:33:47
Summary:     Use the install_command option for all installs.
Affected #:  4 files

diff -r 209de3d6bababd1af01fe0ae8d2488fb0d3d4198 -r 
16f82639efc66e312833a5eadbe9b07cc15b09ea tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -463,14 +463,20 @@
         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("""

diff -r 209de3d6bababd1af01fe0ae8d2488fb0d3d4198 -r 
16f82639efc66e312833a5eadbe9b07cc15b09ea tests/test_venv.py
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -512,12 +512,11 @@
         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
 
@@ -570,13 +569,13 @@
     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]

diff -r 209de3d6bababd1af01fe0ae8d2488fb0d3d4198 -r 
16f82639efc66e312833a5eadbe9b07cc15b09ea tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -331,8 +331,15 @@
             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):

diff -r 209de3d6bababd1af01fe0ae8d2488fb0d3d4198 -r 
16f82639efc66e312833a5eadbe9b07cc15b09ea tox/_venv.py
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -261,27 +261,26 @@
         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)
@@ -307,7 +306,7 @@
         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


https://bitbucket.org/hpk42/tox/commits/b412f4665b54/
Changeset:   b412f4665b54
User:        carljm
Date:        2013-08-09 01:43:47
Summary:     Avoid adding --download-cache option to non-pip custom installers.
Affected #:  2 files

diff -r 16f82639efc66e312833a5eadbe9b07cc15b09ea -r 
b412f4665b54b1084824aa8065d374fb859ea589 tests/test_venv.py
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -585,6 +585,21 @@
     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 -r 16f82639efc66e312833a5eadbe9b07cc15b09ea -r 
b412f4665b54b1084824aa8065d374fb859ea589 tox/_venv.py
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -257,25 +257,28 @@
                 "%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]


https://bitbucket.org/hpk42/tox/commits/269dc66f1f5e/
Changeset:   269dc66f1f5e
User:        carljm
Date:        2013-08-09 02:07:49
Summary:     Add documentation for install_command option.
Affected #:  1 file

diff -r b412f4665b54b1084824aa8065d374fb859ea589 -r 
269dc66f1f5e4d954854fb884731020758226f77 doc/config.txt
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -76,6 +76,22 @@
     For eventually performing a call to ``subprocess.Popen(args, ...)``
     ``args`` are determined by splitting the whole command by whitespace.
 
+.. confval:: install_command=ARGV
+
+    .. versionadded:: 1.6
+
+    the command to be used for installing packages into the virtual
+    environment; both the sdist for the package under test and any
+    defined dependencies. Must contain the substitution key
+    ``{packages}`` which will be replaced by the packages to
+    install. May also contain the substitution key ``{opts}``, which
+    will be replaced by the ``-i`` option to specify index server
+    (according to :confval:`indexserver` and the ``:indexserver:dep``
+    syntax of :confval:`deps`) and the ``--download-cache`` option, if
+    you've specified :confval:`downloadcache` and your
+    :confval:`install_command` begins with ``pip``.  **default**: ``pip
+    install {opts} {packages}``
+
 .. confval:: whitelist_externals=MULTI-LINE-LIST
 
     each line specifies a command name (in glob-style pattern format)


https://bitbucket.org/hpk42/tox/commits/15e7d325f4b6/
Changeset:   15e7d325f4b6
User:        carljm
Date:        2013-08-10 01:32:32
Summary:     Add test for IniReader.getargv.
Affected #:  1 file

diff -r 269dc66f1f5e4d954854fb884731020758226f77 -r 
15e7d325f4b682677756bb69ab61650e0c0a20b6 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -320,6 +320,16 @@
         assert reader.getargvlist('section', 'key')[0] == expected
 
 
+    def test_getargv(self, newconfig):
+        config = newconfig("""
+            [section]
+            key=some command "with quoting"
+        """)
+        reader = IniReader(config._cfg)
+        expected = ['some', 'command', 'with quoting']
+        assert reader.getargv('section', 'key') == expected
+
+
     def test_getpath(self, tmpdir, newconfig):
         config = newconfig("""
             [section]


https://bitbucket.org/hpk42/tox/commits/c5bf99a270bb/
Changeset:   c5bf99a270bb
User:        carljm
Date:        2013-08-10 01:56:20
Summary:     Don't pass --download-cache option to installer if downloadcache 
option is not in config.
Affected #:  3 files

diff -r 15e7d325f4b682677756bb69ab61650e0c0a20b6 -r 
c5bf99a270bb820b040f2090948dce3b27642569 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -488,6 +488,30 @@
             install_command=pip install
         """)
 
+    def test_downloadcache(self, newconfig, monkeypatch):
+        monkeypatch.delenv("PIP_DOWNLOAD_CACHE", raising=False)
+        config = newconfig("""
+            [testenv]
+            downloadcache=/the/cache
+        """)
+        envconfig = config.envconfigs['python']
+        assert envconfig.downloadcache == '/the/cache'
+
+    def test_downloadcache_env_override(self, newconfig, monkeypatch):
+        monkeypatch.setenv("PIP_DOWNLOAD_CACHE", '/from/env')
+        config = newconfig("""
+            [testenv]
+            downloadcache=/from/config
+        """)
+        envconfig = config.envconfigs['python']
+        assert envconfig.downloadcache == '/from/env'
+
+    def test_downloadcache_only_if_in_config(self, newconfig, tmpdir, 
monkeypatch):
+        monkeypatch.setenv("PIP_DOWNLOAD_CACHE", tmpdir)
+        config = newconfig('')
+        envconfig = config.envconfigs['python']
+        assert not envconfig.downloadcache
+
     def test_simple(tmpdir, newconfig):
         config = newconfig("""
             [testenv:py24]

diff -r 15e7d325f4b682677756bb69ab61650e0c0a20b6 -r 
c5bf99a270bb820b040f2090948dce3b27642569 tests/test_venv.py
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -208,10 +208,6 @@
     assert l[1].cwd == venv.envconfig.envlogdir
     assert "pip" in str(args[0])
     assert args[1] == "install"
-    if envdc:
-        assert venv.envconfig.downloadcache == tmpdir
-    else:
-        assert not venv.envconfig.downloadcache
     assert "dep1" in args
     assert "dep2" in args
     deps = list(filter(None, [x[1] for x in venv._getliveconfig().deps]))

diff -r 15e7d325f4b682677756bb69ab61650e0c0a20b6 -r 
c5bf99a270bb820b040f2090948dce3b27642569 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -326,10 +326,10 @@
         vc.distribute = reader.getbool(section, "distribute", False)
         vc.sitepackages = reader.getbool(section, "sitepackages", False)
         vc.downloadcache = None
-        downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", None)
-        if not downloadcache:
-            downloadcache = reader.getdefault(section, "downloadcache")
+        downloadcache = reader.getdefault(section, "downloadcache")
         if downloadcache:
+            # env var, if present, takes precedence
+            downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", downloadcache)
             vc.downloadcache = py.path.local(downloadcache)
         vc.install_command_argv = reader.getargv(
             section,


https://bitbucket.org/hpk42/tox/commits/136e0f1a8a93/
Changeset:   136e0f1a8a93
User:        carljm
Date:        2013-08-10 02:08:34
Summary:     Add --download-cache if set in config; don't try to check 
installer.
Affected #:  2 files

diff -r c5bf99a270bb820b040f2090948dce3b27642569 -r 
136e0f1a8a93cb52939fa37a746806e3d9a3daea doc/config.txt
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -87,10 +87,14 @@
     install. May also contain the substitution key ``{opts}``, which
     will be replaced by the ``-i`` option to specify index server
     (according to :confval:`indexserver` and the ``:indexserver:dep``
-    syntax of :confval:`deps`) and the ``--download-cache`` option, if
-    you've specified :confval:`downloadcache` and your
-    :confval:`install_command` begins with ``pip``.  **default**: ``pip
-    install {opts} {packages}``
+    syntax of :confval:`deps`) and the ``--download-cache`` option (if
+    you've specified :confval:`downloadcache`). If your installer does
+    not support ``-i`` and ``--download-cache`` command-line options,
+    you should not use :confval:`indexserver` or
+    :confval:`downloadcache`, and/or your :confval:`install_command`
+    should not include the ``{opts}`` substitution key (in which case
+    those options will have no effect).
+    **default**: ``pip install {opts} {packages}``
 
 .. confval:: whitelist_externals=MULTI-LINE-LIST
 
@@ -133,9 +137,11 @@
 
 .. confval:: downloadcache=path
 
-    (pip only) use this directory for caching downloads.  This value
-    is overriden by the environment variable ``PIP_DOWNLOAD_CACHE``
-    if it exists.
+    use this directory for caching downloads.  This value is overriden
+    by the environment variable ``PIP_DOWNLOAD_CACHE`` if it exists. If
+    you specify a custom :confval:`install_command` that uses an
+    installer other than pip, your installer must support the
+    `--download-cache` command-line option.
     **default**: no download cache will be used.
     **note**: if creating multiple environments use of a download cache greatly
     speeds up the testing process.

diff -r c5bf99a270bb820b040f2090948dce3b27642569 -r 
136e0f1a8a93cb52939fa37a746806e3d9a3daea tox/_venv.py
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -257,28 +257,25 @@
                 "%s" % depinfo)
             self._install(deps, action=action)
 
-    def _installopts(self, indexserver, is_pip):
+    def _installopts(self, indexserver):
         l = []
         if indexserver:
             l += ["-i", indexserver]
-        if is_pip and self.envconfig.downloadcache:
+        if 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[:]
-        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"
+        # 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
         if '{opts}' in argv:
             i = argv.index('{opts}')
-            argv[i:i+1] = self._installopts(indexserver, is_pip)
+            argv[i:i+1] = self._installopts(indexserver)
         for x in ('PIP_RESPECT_VIRTUALENV', 'PIP_REQUIRE_VIRTUALENV'):
             try:
                 del os.environ[x]


https://bitbucket.org/hpk42/tox/commits/50d991641429/
Changeset:   50d991641429
User:        carljm
Date:        2013-08-10 02:12:46
Summary:     Clarify that usedevelop uses pip's -e option.
Affected #:  1 file

diff -r 136e0f1a8a93cb52939fa37a746806e3d9a3daea -r 
50d991641429bff80344b3c98d0ccad74e1a5015 doc/config.txt
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -211,8 +211,11 @@
 
     .. versionadded:: 1.6
 
-    Install the current package in development mode with "setup.py develop"
-    instead of installing from the ``sdist`` package.
+    Install the current package in development mode with "setup.py
+    develop" instead of installing from the ``sdist`` package. (This
+    uses pip's `-e` option, so should be avoided if you've specified a
+    custom :confval:`install_command` that does not support ``-e``).
+
     **default**: ``False``

Repository URL: https://bitbucket.org/hpk42/tox/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
http://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to