diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2014-09-20 05:48:23 +0200 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2014-09-20 05:48:23 +0200 |
commit | 5e3e84b4fc4dc75d520b8e0e894811e3e2c88f56 (patch) | |
tree | 163fb7a2d00d1060191766184ba2bb080d103bfb /bin/portageq | |
parent | _solve_..slot_conflicts: fix bug #522084 (diff) | |
download | portage-5e3e84b4fc4dc75d520b8e0e894811e3e2c88f56.tar.gz portage-5e3e84b4fc4dc75d520b8e0e894811e3e2c88f56.tar.bz2 portage-5e3e84b4fc4dc75d520b8e0e894811e3e2c88f56.zip |
Update sys.path in scripts only when using not installed instance of Portage.
Modules of installed instance of Portage are now placed in standard location,
which is included in default sys.path.
Diffstat (limited to 'bin/portageq')
-rwxr-xr-x | bin/portageq | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/bin/portageq b/bin/portageq index 79818f679..4d5cc197a 100755 --- a/bin/portageq +++ b/bin/portageq @@ -23,18 +23,22 @@ except KeyboardInterrupt: import os import types -# Avoid sandbox violations after python upgrade. -pym_path = os.path.join(os.path.dirname( - os.path.dirname(os.path.realpath(__file__))), "pym") +if os.path.isfile(os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), ".portage_not_installed")): + pym_paths = [os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")] + sys.path.insert(0, pym_paths[0]) +else: + import distutils.sysconfig + pym_paths = [os.path.join(distutils.sysconfig.get_python_lib(), x) for x in ("_emerge", "portage")] +# Avoid sandbox violations after Python upgrade. if os.environ.get("SANDBOX_ON") == "1": sandbox_write = os.environ.get("SANDBOX_WRITE", "").split(":") - if pym_path not in sandbox_write: - sandbox_write.append(pym_path) - os.environ["SANDBOX_WRITE"] = \ - ":".join(filter(None, sandbox_write)) - del sandbox_write + for pym_path in pym_paths: + if pym_path not in sandbox_write: + sandbox_write.append(pym_path) + os.environ["SANDBOX_WRITE"] = ":".join(filter(None, sandbox_write)) + del pym_path, sandbox_write +del pym_paths -sys.path.insert(0, pym_path) import portage portage._internal_caller = True from portage import os |