saltstack/salt — pull request #2953 by ryanschneider (2012-12-19 20:59:21+00:00)
Title: Explicitly add the portage lib to sys.path if not found.

Gentoo's portage seems to use some magic in adding /usr/lib/portage/pym to the PYTHONPATH without actually changing that environment variable. As such, when running in a virtualenv, 'import porage' fails.

This change follows the convention used in other Portage tools (e.g. gentoolkit, which is part of portage) where /usr/lib/portage/pym is explicitly added to sys.path. I only do this if the dir actually exists and the initial attempt to import portage failed.

This allows one to run:

```
./bin/salt-call -l debug --local -c /path/to/virutalenv/etc/salt pkg.list_pkgs
```
In a virtualenv on Gentoo, where previously it would fail when the portage package was actually used.