demianw/tract_querier — pull request #13 by jchoude (2014-07-09 13:35:23+00:00)
Title: Improve the way the default queries search path is searched

The default queries search path was assumed to be 4 levels higher in the hierarchy. However, in some specific cases, that may not be the case.

For example, on Ubuntu 12.04, trying to pip install the Tract Querier in a Python Virtual Environment (using virtualenv v. 1.11.6), the path that is found for __file__ in __init.py__ is one level too deep. In that case, the heuristic of 4 levels higher in the hierarchy doesn't work, resulting in the tract_querier script failing to find FreeSurfer.qry file.

To overcome this, we can use the sysconfig get_path function. The queries are normally in that folder. We also explore one level higher if the path is not found, to overcome the additionnal local/ subdirectory in a venv.

Was tested on OSX with and without a virtual environment on Anaconda, and on Ubuntu 12.04 with and without a Virtual Environment.

If you want a list of the paths found under various circumstances from my tests, please let me know.