gentoolkit since 0.3.0 has been installed into the usual site-packages
directory, so there shouldn't be any need to monkey with sys.path.
If the user is running an older version that is under
/usr/lib/gentoolkit, we fall back to that. Appending it to sys.path
(vs. prepending) allows us to override its location with PYTHONPATH:
PYTHONPATH=".:$HOME/src/gentoolkit/pym" nosetests tests/test_portage_utils.py
#portage <= 2.1
from portage import portage_dep
-sys.path.insert(0, "/usr/lib/gentoolkit/pym")
-import gentoolkit
+try:
+ import gentoolkit # gentoolkit since 0.3.0 are installed as usual
+except ImportError: # earlier versions in '/usr/lib/gentoolkit/pym'
+ sys.path.append(os.path.join('/usr', 'lib', 'gentoolkit', 'pym'))
+ import gentoolkit
import gentoolkit.query