How do I run tox in a project that has no setup.py?

I would like to use tox to run my unittests in two virtualenvs, since my application has to support 2 different Python versions.

My problem is that tox requires a setup.py, but I have none since my application is not a module and has its own installer. For now I don't want to go through the hassle of automating the install process as to work with setup.py, I just want to run my unittests without having to write a setup.py.

Is that possible? Or how can I write an "empty" setup.py that simply does nothing? Can you point me towards some documentation on the subject (the distutils documentation explains how to write a meaningful setup.py, not an empty one)?


Solution 1:

After digging inside the source code, I found a scarcely documented option in tox.ini that skips sdist:

[tox]
skipsdist = BOOL    # defaults to false

Setting this to True I got what I wanted, saving me the effort of writing a meaningful setup.py

Solution 2:

If you have an application (with a requirements.txt), rather than a project that you are going to distribute (which would have a setup.py instead), your tox.ini should look something like this:

[tox]
skipsdist = True

[testenv]
deps = -r{toxinidir}/requirements.txt

Found this answer originally from David Murphy's blog, but the page is no longer available, you can find an archived version here: https://web.archive.org/web/20150112223937/https://blog.schwuk.com/2014/03/19/using-tox-django-projects/

(Original link, now dead: http://blog.schwuk.com/2014/03/19/using-tox-django-projects/ )

Solution 3:

This is my tox.ini file content for Django project by multiple settings:

[tox]
envlist = py36-{accounting,content,media}_settings
skipsdist = true

[testenv]
commands = python {toxinidir}/manage.py test
deps = -r{toxinidir}/requirements.txt

setenv =
    accounting_settings: DJANGO_SETTINGS_MODULE=my_project.settings.accounting
    contents_settings: DJANGO_SETTINGS_MODULE=my_project.settings.contents
    media_settings: DJANGO_SETTINGS_MODULE=my_project.settings.media

Solution 4:

I also had to remove usedevelop = true from my conf.

My configuration was looking like that:

[tox]
envlist = flake8,py36

[testenv]
usedevelop = true
install_command = pip install -U {opts} {packages}
deps =
    py36: -r requirements.txt
    py36: -r requirements-test.txt
    flake8: flake8
commands=
    flake8: flake8 app tests --ignore=E501,W503
    py36: pytest {toxinidir}/tests {posargs}

I added skipsdist = true as the other answers suggest. But it was not enough. As said above, also removing usedevelop = true did the trick.