#20 Merged
Repository
msabramo/tox_quickstart tox_quickstart
Branch
default
Repository
hpk42/tox tox
Branch
default

Add a `tox-quickstart` command

Author
  1. Marc Abramowitz avatarMarc Abramowitz
Reviewers
Description

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 setup.py test
    - nosetests package.module
    - trial package.module
> Command to run to test project [{envpython} setup.py 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 (http://tox.testrun.org/) 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.

[tox]
envlist = py27, py30, py31, py32, py33, pypy

[testenv]
commands = {envpython} setup.py test
deps = 
    nose
    blessings

Possible future enhancements:

  • Attempt to automatically determine dependencies (maybe by looking at what's installed in the current virtualenv or scanning the setup.py 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. "setup.py 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/test_quickstart.py, 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: http://codereview.appspot.com/6847080/ 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.

  6. Marc Abramowitz author

    Hey Holger, I think in a1c66429ad41, you accidentally overwrote tox.ini with one generated by tox-quickstart. I almost did this myself several times, but was lucky enough to notice and do hg revert tox.ini. :-)

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.