From 5e3e84b4fc4dc75d520b8e0e894811e3e2c88f56 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 20 Sep 2014 05:48:23 +0200 Subject: 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. --- bin/portageq | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'bin/portageq') 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 -- cgit v1.2.3-65-gdbad