Add a `tox-quickstart` command

#20 Merged
  1. Marc Abramowitz

Hi Holger et al,

This PR adds a new command called tox-quickstart (inspired by sphinx-quickstart), which asks the user a few questions and then spits out a simple tox.ini file for them to get started with.

I see this as valuable for beginners and veterans alike, as when I start a new project, I often have to find some other recent project of mine and then cargo cult the tox.ini from that one. I will enjoy using tox-quickstart instead. :-)

(tox.venv)marca@SCML-MarcA:~/dev/hg-repos/tox_quickstart/sandbox$ tox-quickstart 
Welcome to the Tox 1.4.3.dev0 quickstart utility.

This utility will ask you a few questions and then generate a simple tox.ini
file to help get you started using tox.

Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).

> Test your project with py24 (Y/n) [Y]: n
> Test your project with py25 (Y/n) [Y]: n
> Test your project with py26 (Y/n) [Y]: n
> Test your project with py27 (Y/n) [Y]: 
> Test your project with py30 (Y/n) [Y]: 
> Test your project with py31 (Y/n) [Y]: 
> Test your project with py32 (Y/n) [Y]: 
> Test your project with py33 (Y/n) [Y]: 
> Test your project with pypy (Y/n) [Y]: 
> Test your project with jython (Y/n) [Y]: n

What command should be used to test your project -- examples:
    - python test
    - nosetests package.module
    - trial package.module
> Command to run to test project [{envpython} test]: 

What dependencies does your project have?
> Comma-separated list of dependencies [ ]: nose, blessings

Creating file tox.ini.

Finished: A tox.ini file has been created.

Execute `tox` to test your project.

(tox.venv)marca@SCML-MarcA:~/dev/hg-repos/tox_quickstart/sandbox$ cat tox.ini
# Tox ( is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

envlist = py27, py30, py31, py32, py33, pypy

commands = {envpython} test
deps = 

Possible future enhancements:

  • Attempt to automatically determine dependencies (maybe by looking at what's installed in the current virtualenv or scanning the or requirements.txt or even more crazily, running the tests after installing a magic import hook that tracks dependencies!)
  • Possibly generate clauses that illustrates more complex scenarios like when some environments require special dependencies in addition to the base dependencies.

Comments (13)

  1. Holger Krekel repo owner

    a good idea i think. Regarding automatic deps what about a testrunner question, e.g. " test", "nosetests", "pytest" and "trial" - which would add the appropriate deps and suggest a default command (maybe auto detecting test(s) or testing directories).

    To add such a PR, there definitely need to be tests which of course are some work - they should test all these default variations.

  2. Marc Abramowitz author

    Hi Holger,

    I just added tests/, which does some basic tests of the new functionality.

    I haven't played yet with your idea of having a testrunner question - would you like me to work on that in this PR or would you like to merge what we have thus far and then work on refining tox-quickstart perhaps in another PR?

  3. Holger Krekel repo owner

    I've done a little code-review here: we should also mention quickstart usage in doc/index.txt btw. With those changes i am ready to pull.

    In generall, i think there should just be a testrunner question. In the future i expect tox to have direct support for specifying a "testrunner" with generalized "junitxml", "coverage", etc. options that will map to appropriate options with py.test and nose (and be rejected with "setuptest" and "trial") and will of course include dependencies as appropriate.

  4. Marc Abramowitz author

    Hi Holger,

    Thanks for the code review! I went ahead and made the changes that you suggested, including adding a short blurb about tox-quickstart to doc/index.txt.

    The one thing that bugs me a little is how many questions there are for each of the individual Python environments -- that part is a bit tedious to go through. I am toying around in my head with other ideas like:

    • just having the user specify the comma-separated list (although this is what one would do in a tox.ini so this kind of diminishes the value of tox-quickstart)
    • having the user type each env they want one at a time and then enter a blank to indicate that they're done.
    • letting the user pick from a few pre-canned choices of envlists -- e.g.: "python2only" == "py24, py25, py26, py27", "modernpythons" == "py27, py32, py33, pypy"

    I'm not sure which one I like and even if I did know, community members might have very different opinions, so I wonder if we should just put it out there and see how the community responds to it and then it can be tweaked later...

  5. Holger Krekel repo owner

    What about offering "py27", "py27,py33", "py33" and lastly all possible choices and printing the general advise that you can go and delete the ones from tox.ini you don't need?

    As to getting feedback from people using it, that'd be good. Not sure we are going to get it from people using tox-quickstart. Maybe we should print a link to the tox config documentation at the end.