From 7f1750a5990cf269bba6e0105e557f3bb91a1e37 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 25 Jun 2016 13:06:55 +0200 Subject: addresses issue66: add --workdir option to override where tox stores its ".tox" directory to "pip freeze" to obtain the list of installed packages. Thanks Ted Shaw, Holger Krekel. close issue66: add documentation to jenkins page on how to avoid "too long shebang" lines when calling pip from tox. Note that we can not use "python -m pip install X" by default because the latter adds the CWD and pip will think X is installed if it is there. "pip install X" does not do that. (experimental) New feature: When a search for a config file fails, tox tries loading --- CHANGELOG | 22 ++++++++++++---------- doc/config.txt | 4 ++-- doc/example/jenkins.txt | 20 +++++++++++++++++++- doc/install.txt | 2 +- setup.py | 2 +- tests/test_venv.py | 10 +++++----- tox/config.py | 4 ++-- 7 files changed, 42 insertions(+), 22 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 999ba96..a195066 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,21 +5,23 @@ chars "{" and "}" to appear in your commands or other ini values. Thanks John Vandenberg. -- add --workdir option to override where tox stores its ".tox" directory +- addresses issue66: add --workdir option to override where tox stores its ".tox" directory and all of the virtualenv environment. Thanks Danring. - 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. + to "pip freeze" to obtain the list of installed packages. + 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. +- close issue66: add documentation to jenkins page on how to avoid + "too long shebang" lines when calling pip from tox. Note that we + can not use "python -m pip install X" by default because the latter + adds the CWD and pip will think X is installed if it is there. + "pip install X" does not do that. -- New feature: When a search for a config file fails, tox tries loading +- new list_dependencies_command to influence how tox determines + which dependencies are installed in a testenv. + +- (experimental) New feature: When a search for a config file fails, tox tries loading setup.cfg with a section prefix of "tox". - fix issue275: Introduce hooks ``tox_runtest_pre``` and diff --git a/doc/config.txt b/doc/config.txt index 229f357..d99e91c 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -105,7 +105,7 @@ Complete list of settings that you can put into ``testenv*`` sections: **default**:: - python -m pip install {opts} {packages} + pip install {opts} {packages} .. confval:: list_dependencies_command @@ -117,7 +117,7 @@ Complete list of settings that you can put into ``testenv*`` sections: **default**:: - python -m pip freeze + pip freeze .. confval:: ignore_errors=True|False(default) diff --git a/doc/example/jenkins.txt b/doc/example/jenkins.txt index b93bec4..94cb22d 100644 --- a/doc/example/jenkins.txt +++ b/doc/example/jenkins.txt @@ -44,7 +44,7 @@ for example with ``py.test`` it is done like this: .. note:: This feature is broken currently because "toxbootstrap.py" - has been removed. Please file an issue if you'd like to + has been removed. Please file an issue if you'd like to see it back. If you manage many Jenkins slaves and want to use the latest officially @@ -151,6 +151,24 @@ So if you are using defaults you can re-use and debug exactly the same ``tox.ini`` file and make use of automatic sharing of your artifacts between runs or Jenkins jobs. + +Avoiding the "path too long" error with long shebang lines +--------------------------------------------------------------- + +If you are using Jenkins builds you might run into the issue +that tox can not call ``pip`` because the so called "shebang" +line is too long. There is a limit of 127 chars on some systems. +Probably the best way to fix the problem is to use the +new ``--workdir`` option which tells tox to use a specific +directory for its virtualenvironments. Set it to some unique +enough short path. If somebody is interested to do a PR +you could add a new option to tox which uses a random +directory for storing its workdir results and removes +it after the tox run finishes. This could be used +from CI environments where you probably anyway want +to recreate everything on new runs. + + .. include:: ../links.txt diff --git a/doc/install.txt b/doc/install.txt index 7e5d547..982cefb 100644 --- a/doc/install.txt +++ b/doc/install.txt @@ -4,7 +4,7 @@ tox installation Install info in a nutshell ---------------------------------- -**Pythons**: CPython 2.6-3.3, Jython-2.5.1, pypy-1.9ff +**Pythons**: CPython 2.6-3.5, Jython-2.5.1, pypy-1.9ff **Operating systems**: Linux, Windows, OSX, Unix diff --git a/setup.py b/setup.py index 2cefdc8..cc49e89 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ def has_environment_marker_support(): def main(): version = sys.version_info[:2] - install_requires = ['virtualenv>=1.11.2', 'py>=1.4.17', 'pluggy>=0.3.0,<0.4.0'] + install_requires = ['virtualenv>=1.11.2', 'py>=1.4.17', 'pluggy>=0.3.0,<0.5.0'] extras_require = {} if has_environment_marker_support(): extras_require[':python_version=="2.6"'] = ['argparse'] diff --git a/tests/test_venv.py b/tests/test_venv.py index 0af9977..86fbc46 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -138,8 +138,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[2]) - assert args[3] == "install" + assert "pip" in str(args[0]) + assert args[1] == "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")] @@ -169,7 +169,7 @@ def test_install_downloadcache(newmocksession, monkeypatch, tmpdir, envdc): args = l[-1].args assert l[-1].cwd == venv.envconfig.config.toxinidir assert "pip" in str(args) - assert args[3] == "install" + assert args[1] == "install" assert "dep1" in args assert "dep2" in args deps = list(filter(None, [x[1] for x in venv._getliveconfig().deps])) @@ -366,7 +366,7 @@ def test_install_python3(tmpdir, newmocksession): venv._install(["hello"], action=action) assert len(l) == 1 args = l[0].args - assert "pip" in [str(x) for x in args] + assert "pip" in args[0] for x in args: assert "--download-cache" not in args, args @@ -598,7 +598,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[2] + assert 'pip' in l[0].args[0] assert 'install' in l[0].args env = l[0].env assert env is not None diff --git a/tox/config.py b/tox/config.py index 0b90786..ad453f6 100644 --- a/tox/config.py +++ b/tox/config.py @@ -182,7 +182,7 @@ class PosargsOption: class InstallcmdOption: name = "install_command" type = "argv" - default = "python -m pip install {opts} {packages}" + default = "pip install {opts} {packages}" help = "install command for dependencies and package under test." def postprocess(self, testenv_config, value): @@ -529,7 +529,7 @@ def tox_addoption(parser): parser.add_testenv_attribute( name="list_dependencies_command", type="argv", - default="python -m pip freeze", + default="pip freeze", help="list dependencies for a virtual environment") parser.add_testenv_attribute_obj(DepOption()) -- cgit v1.2.1