mardi 23 mai 2017

Tox and lib and lib64 and site-packages

I'm using tox and coverage.py to run tests of my Python project in my continuous build server. I also have a package pkg_x from a vendor (not available on PyPI) that I've installed using python3.5 setup.py install, which puts it in /usr/lib/python3.5/site-packages. Now I need to make that package available to the testing code.

My current tox.ini looks like this:

[tox]
envlist = py35

[testenv]
deps = nose
       coverage
commands = coverage run -m nose []
sitepackages = True

and I run the tests like so:

python3.5 -m tox -- --verbose --with-doctest

That fails spectacularly - none of the dependency packages listed in my local setup.py (e.g. public stuff like more_itertools) can be found, even though it does create directories like .tox/py35/lib/python3.5/site-packages/more_itertools that seem to contain the relevant packages. If I fire up .tox/py35/bin/python3.5, sys.path looks like this:

>>> [re.compile('.*\\.tox').sub('.tox', x) for x in sys.path]
['',
 '.tox/py35/lib64/python35.zip',
 '.tox/py35/lib64/python3.5', 
 '.tox/py35/lib64/python3.5/plat-linux',
 '.tox/py35/lib64/python3.5/lib-dynload',
 '/usr/lib64/python3.5',
 '/usr/lib/python3.5',
 '.tox/py35/lib/python3.5/site-packages']

If I remove the sitepackages = True line from my tox.ini, then I do get farther, in that packages like more_itertools and the rest of the stuff in my setup.py dependencies can now be found, but the vendor package pkg_x I mentioned above still can't be found. And sys.path looks like this:

>>> [re.compile('.*\\.tox').sub('.tox', x) for x in sys.path]
['',
 '.tox/py35/lib64/python35.zip',
 '.tox/py35/lib64/python3.5', 
 '.tox/py35/lib64/python3.5/plat-linux',
 '.tox/py35/lib64/python3.5/lib-dynload',
 '/usr/lib64/python3.5',
 '/usr/lib/python3.5',
 '.tox/py35/lib/python3.5/site-packages',
 '/usr/lib64/python3.5/site-packages',
 '/usr/lib/python3.5/site-packages']

In neither case does .tox/py35/ seem to contain the vendor package pkg_x anywhere. And although the directory /usr/lib/python3.5/site-packages is listed when I fire up .tox/py35/bin/python3.5 manually, pkg_x isn't actually found when running the tests.

It also looks like sitepackages = True has the opposite effect from what it's documented to do at http://ift.tt/2rOivKP , right?

Advice very appreciated!

Aucun commentaire:

Enregistrer un commentaire