summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2016-06-20 16:40:36 +0200
committerholger krekel <holger@merlinux.eu>2016-06-20 16:40:36 +0200
commit6c44042ac2357850365c83e7f31be4d74dd2199f (patch)
tree3716b0612981bec73b9ba8488726f9efef6d8133
parent30ba6a86ca085bb68280244116bb5b68743d376c (diff)
downloadtox-6c44042ac2357850365c83e7f31be4d74dd2199f.tar.gz
fix issue66 by introducing using default "python -m pip"
and introducing list_dependencies_command. (Ted, Holger)
-rw-r--r--CHANGELOG15
-rw-r--r--doc/config.txt15
-rw-r--r--setup.py2
-rw-r--r--tests/test_venv.py12
-rw-r--r--tox.ini7
-rw-r--r--tox/__init__.py2
-rw-r--r--tox/_pytestplugin.py3
-rw-r--r--tox/config.py9
-rw-r--r--tox/session.py5
9 files changed, 58 insertions, 12 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3ec0abd..3be2703 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,18 @@
+2.4.0
+-----
+
+- introduce per-venv list_dependencies_command which defaults
+ to "python -m pip freeze" to obtain the list of installed packages.
+ If you need to run python2.6 you need to configure it to
+ something like "pip freeze". Thanks Ted Shaw, Holger Krekel.
+
+- fix issue66, issue121: change install_command to use "python -m pip"
+ by default instead of "pip ..." directly which avoids long shebang
+ issues. If you need to run python2.6 you need to configure it to
+ something like "pip install {opts} {packages}". Thanks Ted Shaw,
+ Holger Krekel.
+
+
2.3.2
-----
diff --git a/doc/config.txt b/doc/config.txt
index 205b22a..229f357 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -105,7 +105,20 @@ Complete list of settings that you can put into ``testenv*`` sections:
**default**::
- pip install {opts} {packages}
+ python -m pip install {opts} {packages}
+
+
+.. confval:: list_dependencies_command
+
+ .. versionadded:: 2.4
+
+ the ``list_dependencies_command`` setting is used for listing
+ the packages installed into the virtual environment.
+
+ **default**::
+
+ python -m pip freeze
+
.. confval:: ignore_errors=True|False(default)
diff --git a/setup.py b/setup.py
index 7662332..2cefdc8 100644
--- a/setup.py
+++ b/setup.py
@@ -48,7 +48,7 @@ def main():
description='virtualenv-based automation of test activities',
long_description=open("README.rst").read(),
url='http://tox.testrun.org/',
- version='2.3.2',
+ version='2.4.0.dev1',
license='http://opensource.org/licenses/MIT',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 4ab3b06..30bdf3c 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -137,8 +137,8 @@ def test_install_deps_wildcard(newmocksession):
assert len(l) == 2
args = l[-1].args
assert l[-1].cwd == venv.envconfig.config.toxinidir
- assert "pip" in str(args[0])
- assert args[1] == "install"
+ assert "pip" in str(args[2])
+ assert args[3] == "install"
# arg = "--download-cache=" + str(venv.envconfig.downloadcache)
# assert arg in args[2:]
args = [arg for arg in args if str(arg).endswith("dep1-1.1.zip")]
@@ -167,8 +167,8 @@ def test_install_downloadcache(newmocksession, monkeypatch, tmpdir, envdc):
assert len(l) == 2
args = l[-1].args
assert l[-1].cwd == venv.envconfig.config.toxinidir
- assert "pip" in str(args[0])
- assert args[1] == "install"
+ assert "pip" in str(args)
+ assert args[3] == "install"
assert "dep1" in args
assert "dep2" in args
deps = list(filter(None, [x[1] for x in venv._getliveconfig().deps]))
@@ -365,7 +365,7 @@ def test_install_python3(tmpdir, newmocksession):
venv._install(["hello"], action=action)
assert len(l) == 1
args = l[0].args
- assert 'pip' in str(args[0])
+ assert "pip" in [str(x) for x in args]
for x in args:
assert "--download-cache" not in args, args
@@ -597,7 +597,7 @@ def test_run_install_command(newmocksession):
venv.run_install_command(packages=["whatever"], action=action)
l = mocksession._pcalls
assert len(l) == 1
- assert 'pip' in l[0].args[0]
+ assert 'pip' in l[0].args[2]
assert 'install' in l[0].args
env = l[0].env
assert env is not None
diff --git a/tox.ini b/tox.ini
index 17efc83..3dd30dc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,6 +13,13 @@ deps=pytest>=2.3.5
[testenv:py26-bare]
deps =
commands = tox -h
+install_command = pip install {opts} {packages}
+list_dependencies_command = pip freeze
+
+[testenv:py26]
+install_command = pip install {opts} {packages}
+list_dependencies_command = pip freeze
+
[testenv:docs]
basepython=python
diff --git a/tox/__init__.py b/tox/__init__.py
index 6991c90..baf651b 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '2.3.2'
+__version__ = '2.4.0.dev1'
from .hookspecs import hookspec, hookimpl # noqa
diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py
index f15d2ec..d7bff0c 100644
--- a/tox/_pytestplugin.py
+++ b/tox/_pytestplugin.py
@@ -195,6 +195,9 @@ class Cmd:
return py.std.subprocess.Popen(argv, stdout=stdout, stderr=stderr, **kw)
def run(self, *argv):
+ if argv[0] == "tox" and sys.version_info[:2] < (2,7):
+ pytest.skip("can not run tests involving calling tox on python2.6. "
+ "(and python2.6 is about to be deprecated anyway)")
argv = [str(x) for x in argv]
assert py.path.local.sysfind(str(argv[0])), argv[0]
p1 = self.tmpdir.join("stdout")
diff --git a/tox/config.py b/tox/config.py
index 78d070a..1fd702c 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -181,7 +181,7 @@ class PosargsOption:
class InstallcmdOption:
name = "install_command"
type = "argv"
- default = "pip install {opts} {packages}"
+ default = "python -m pip install {opts} {packages}"
help = "install command for dependencies and package under test."
def postprocess(self, testenv_config, value):
@@ -518,6 +518,13 @@ def tox_addoption(parser):
help="install package in develop/editable mode")
parser.add_testenv_attribute_obj(InstallcmdOption())
+
+ parser.add_testenv_attribute(
+ name = "list_dependencies_command",
+ type = "argv",
+ default = "python -m pip freeze",
+ help = "list dependencies for a virtual environment")
+
parser.add_testenv_attribute_obj(DepOption())
parser.add_testenv_attribute(
diff --git a/tox/session.py b/tox/session.py
index 029b06b..1d51b92 100644
--- a/tox/session.py
+++ b/tox/session.py
@@ -537,8 +537,9 @@ class Session:
# write out version dependency information
action = self.newaction(venv, "envreport")
with action:
- pip = venv.getcommandpath("pip")
- output = venv._pcall([str(pip), "freeze"],
+ python = venv.getcommandpath("python")
+ args = venv.envconfig.list_dependencies_command
+ output = venv._pcall(args,
cwd=self.config.toxinidir,
action=action)
# the output contains a mime-header, skip it