[TIP] detox and Python-version-specific install_requires

Marius Gedminas marius at gedmin.as
Wed Dec 10 08:57:47 PST 2014

Sometimes the set of required libraries varies depending on Python
version.  E.g. you might need 'argparse' on Python 2.6.  Or you're
supporting a Python version (say, 3.2) that used to be is no longer
supported by one of your dependencies (Pygments), unless you ask for an
older release.

My attempts to solve this is by writing conditional code in setup.py,
something like:

            'pygments' + (' < 2.0a' if sys.version_info[:2] == (3, 2) else '')

Now if I run the tests for this package with tox, everything works
great.  But I want to run the tests often, so I want them to be fast, so
I want to use detox.  And there I run into problems.

Detox runs

  .tox/py26/bin/python setup.py test
  .tox/py27/bin/python setup.py test
  .tox/py32/bin/python setup.py test
  .tox/py33/bin/python setup.py test
  .tox/py34/bin/python setup.py test

in parallel and they stomp over each other's src/restview.egg-info/requires.txt,
leading to failures when suddenly the py27 test fails because it thinks
it requires Pygments < 2.0a1 while its virtualenv already has a newer
version left over from an older invocation.

Actually never mind, I think I solved this by not using 'python setup.py
test'.  At one point it seemed to be becoming the standard way for a
Python package to run its test suite, but that was before tox.

(Sending this email anyway since I already wrote it.  And hey, maybe
someone will google it up in the list archives in 2016 and find it

Marius Gedminas
Key emulation:
[ ] Intuitive
[*] Emacs        (Seen in an MCEdit dialog) 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 173 bytes
Desc: Digital signature
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20141210/5e91d235/attachment.pgp>

More information about the testing-in-python mailing list