When attempting to run pytest on daf_butler I had several errors related to using features that were only in sqlalchemy 1.2.X, and the version in use was 1.1.X.
I verified that with eups, the correct version of sqlalchemy was installed and setup. I then verified that PYTHONPATH was correctly set.
It turns out that I had a version of sqlalchemy 1.1.X installed in site-packages through conda. However, site-packages should be among the last thing searched if PYTHONPATH is set.
I did some digging, but the problem went away when I used the python shell for debugging.
This lead me to looking at the value of sys.path (the list of paths searched and their search order) in a pytest session and in a python shell. Needless to say they were different.
It turns out that pytest has a site.py file that programatically redefines sys.path, and in its re-declaration, it puts site-packages near the top of the list, before anything declared in the PYTHONPATH variable.
The consequence of this is that any package that is setup, through our eups method or any of the other normal python ways, that has a package of the same name in site-packages will not be used.
I don’t have time to dig into this any further at the moment, but the behavior is worrying to me. I’m not sure I trust a package that thinks it knows the order things should happen in better than what I as a user have specified. Then again it may simply be a bug or oversight in pytest.
I mostly wanted to make people aware of this issue, and prompt anyone who has more time to look into this.