2 new commits in tox: https://bitbucket.org/hpk42/tox/commits/eb69ae15b946/ Changeset: eb69ae15b946 User: so...@nur-sober-mc-01.local Date: 2016-06-25 16:47:06+00:00 Summary: refactored proposal Affected #: 1 file
diff -r 489bcd21e06ccc30f1fc85187852815540093c5d -r eb69ae15b94632fc2c206adf01e097ccbefe537a doc/drafts/extend-envs-and-packagebuilds.md --- a/doc/drafts/extend-envs-and-packagebuilds.md +++ b/doc/drafts/extend-envs-and-packagebuilds.md @@ -67,18 +67,89 @@ * Holger: configuration driven. explicitly configuring which packages should be used (default sdist to be used, overridable by concrete env) * Ronny: "package definitions" (this package, this setup command) + matching definitions (matching packages (with wildcards) for environments) -### Feature - builddef -This feature shall allow to specify how to build an artifact in a specific build definition (builddef). +## Proposal -Currently tox uses the current python interpreter to build the artifact (python package) and thus -does not allow to freely choose the interpreter to build with. -This means that as of now build environment and test environment are different by design. +This feature shall allow to specify how plugins can specify new types of package formats and environments to run test +commands in. -Support for different build definitions is implemented by individual tox plugins. -This would result in a collection of plugins supporting different build definitions (e.g. conda, pyenv, docker, rpm) +Such plugins would take care of setting up the environment, create packages and run test commands using hooks provided +by tox. The actual knowledge how to create a certain package format is implement in the plugin. -Default behavior: +Plugin decides which is the required python interpreter to use in order to create the relevant package format. -To keep backwards-compatibility, a python package is built with the python interpreter tox is executed with, -using sdist. This does not require any builddef specification in tox.ini. + +```ini +[tox] +plugins=conda # virtualenv plugin is builtin; intention here is to bail out early in case the specified plugins + # are not installed +envlist=py27,py35 + +[testenv] +package_formats= # new option to specify wanted package formats for test environment using tox factors feature + # defaults to "sdist" if not set + py35: sdist wheel conda # names here are provided by plugins (reserved keywords) + py27: sdist conda +commands = py.test +``` + +Lising tox environments (`tox --list`) would display the following output: + +``` +(sdist) py27 +(conda) py27 +(sdist) py35 +(wheel) py35 +(conda) py35 +``` + +To remain backward-compatible, the package format will not be displayed if only a single package format is specified. + + + +How to skip building a package for a specific factor? + +Illustrate how to exclude a certain package format for a factor: + +```ini +[tox] +plugins=conda +envlist={py27,py35}, py27-xdist + +[testenv] +package_formats=sdist wheel conda +commands = py.test +exclude_package_formats= # new option which filters out packages + py27-xdist: wheel +``` + +Output of `tox --list`: + +``` +(sdist) py27 +(conda) py27 +(sdist) py35 +(wheel) py35 +(conda) py35 +(sdist) py27-xdist +(conda) py27-xdist +``` + + +### Implemenation Details + +``` +tox_package_formats() -> ['conda'] # ['sdist', 'wheel'] +tox_testenv_create(env_meta, package_type) -> # creates an environment for given package, using + # information from env_meta (like .envdir) + # returns: an "env" object which is forwaded to the next hooks +tox_testenv_install(env_meta, package_type, env) -> # installs deps and package into environment +tox_testenv_runtest(env_meta, package_type, env) -> # activates enviroment and runs test commands + +tox_testenv_updated(env_meta, package_type) -> # returns True if hte environment is already up to date + # otherwise, tox will remove the environment completely and + # create a new one +``` + + + https://bitbucket.org/hpk42/tox/commits/19a03d4e500b/ Changeset: 19a03d4e500b User: sober7 Date: 2016-06-25 16:47:48+00:00 Summary: Merged hpk42/tox into default Affected #: 7 files diff -r eb69ae15b94632fc2c206adf01e097ccbefe537a -r 19a03d4e500ba859631bce6f6999de09b1a48cde CHANGELOG --- 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 -r eb69ae15b94632fc2c206adf01e097ccbefe537a -r 19a03d4e500ba859631bce6f6999de09b1a48cde doc/config.txt --- a/doc/config.txt +++ b/doc/config.txt @@ -105,7 +105,7 @@ **default**:: - python -m pip install {opts} {packages} + pip install {opts} {packages} .. confval:: list_dependencies_command @@ -117,7 +117,7 @@ **default**:: - python -m pip freeze + pip freeze .. confval:: ignore_errors=True|False(default) diff -r eb69ae15b94632fc2c206adf01e097ccbefe537a -r 19a03d4e500ba859631bce6f6999de09b1a48cde doc/example/jenkins.txt --- a/doc/example/jenkins.txt +++ b/doc/example/jenkins.txt @@ -44,7 +44,7 @@ .. 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 @@ 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 -r eb69ae15b94632fc2c206adf01e097ccbefe537a -r 19a03d4e500ba859631bce6f6999de09b1a48cde doc/install.txt --- a/doc/install.txt +++ b/doc/install.txt @@ -4,7 +4,7 @@ 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 -r eb69ae15b94632fc2c206adf01e097ccbefe537a -r 19a03d4e500ba859631bce6f6999de09b1a48cde setup.py --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ 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 -r eb69ae15b94632fc2c206adf01e097ccbefe537a -r 19a03d4e500ba859631bce6f6999de09b1a48cde tests/test_venv.py --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -138,8 +138,8 @@ 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 @@ 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 @@ 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 @@ 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 -r eb69ae15b94632fc2c206adf01e097ccbefe537a -r 19a03d4e500ba859631bce6f6999de09b1a48cde tox/config.py --- a/tox/config.py +++ b/tox/config.py @@ -182,7 +182,7 @@ 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 @@ 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()) 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 https://mail.python.org/mailman/listinfo/pytest-commit