From 50f098aee0282d5294b94c8c3c0074b3126724e6 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 2 Sep 2012 14:56:22 -0700 Subject: [PATCH] Unconditionally insert our pym dir in sys.path. This is especially necessary when running in prefix mode, since sys.path may contain the path for a different version of portage. --- bin/archive-conf | 13 ++++++------- bin/binhost-snapshot | 13 +++++-------- bin/clean_locks | 13 +++++-------- bin/dispatch-conf | 12 ++++-------- bin/ebuild | 11 ++++------- bin/egencache | 11 ++++------- bin/emaint | 11 ++++------- bin/emerge | 11 ++++------- bin/env-update | 13 ++++++------- bin/fixpackages | 13 +++++-------- bin/glsa-check | 13 +++++-------- bin/portageq | 9 ++------- bin/quickpkg | 11 ++++------- bin/regenworld | 13 +++++-------- bin/repoman | 10 ++++------ 15 files changed, 67 insertions(+), 110 deletions(-) diff --git a/bin/archive-conf b/bin/archive-conf index 797866817..af34db628 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @@ -12,12 +12,11 @@ from __future__ import print_function import sys -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage + +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os from portage import dispatch_conf diff --git a/bin/binhost-snapshot b/bin/binhost-snapshot index 9d2697d03..fe2cf6b53 100755 --- a/bin/binhost-snapshot +++ b/bin/binhost-snapshot @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import io @@ -13,13 +13,10 @@ try: except ImportError: from urlparse import urlparse -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname( - osp.realpath(__file__))), "pym")) - import portage +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage def parse_args(argv): prog_name = os.path.basename(argv[0]) diff --git a/bin/clean_locks b/bin/clean_locks index 8c4299c92..09ee3e516 100755 --- a/bin/clean_locks +++ b/bin/clean_locks @@ -1,17 +1,14 @@ #!/usr/bin/python -O -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function import sys, errno -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv: diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 35979dbb2..e5f768056 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -16,14 +16,10 @@ from __future__ import print_function from stat import ST_GID, ST_MODE, ST_UID from random import random import atexit, re, shutil, stat, sys - -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os from portage import dispatch_conf from portage import _unicode_decode diff --git a/bin/ebuild b/bin/ebuild index 65e5bef63..a21ef648a 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -64,13 +64,10 @@ parser.add_option("--skip-manifest", help="skip all manifest checks", opts, pargs = parser.parse_args(args=sys.argv[1:]) -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage portage.dep._internal_warnings = True from portage import os from portage import _encodings diff --git a/bin/egencache b/bin/egencache index d0c073c6e..a0766b1f2 100755 --- a/bin/egencache +++ b/bin/egencache @@ -28,13 +28,10 @@ import time import textwrap import re -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os, _encodings, _unicode_encode, _unicode_decode from _emerge.MetadataRegen import MetadataRegen from portage.cache.cache_errors import CacheError, StatCollision diff --git a/bin/emaint b/bin/emaint index bee46c40d..fd9f346b2 100755 --- a/bin/emaint +++ b/bin/emaint @@ -26,13 +26,10 @@ try: except KeyboardInterrupt: sys.exit(1) -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage.emaint.main import emaint_main try: diff --git a/bin/emerge b/bin/emerge index a9a56432c..f618068c3 100755 --- a/bin/emerge +++ b/bin/emerge @@ -35,13 +35,10 @@ else: signal.signal(debug_signum, debug_signal) -try: - from _emerge.main import emerge_main -except ImportError: - from os import path as osp - import sys - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - from _emerge.main import emerge_main +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +from _emerge.main import emerge_main if __name__ == "__main__": import sys diff --git a/bin/env-update b/bin/env-update index 8a69f2bb2..cee3fd683 100755 --- a/bin/env-update +++ b/bin/env-update @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -25,12 +25,11 @@ if len(sys.argv) > 1: print("!!! Invalid command line options!\n") usage(1) -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage + try: portage.env_update(makelinks) except IOError as e: diff --git a/bin/fixpackages b/bin/fixpackages index dc43ed2b3..da08520e5 100755 --- a/bin/fixpackages +++ b/bin/fixpackages @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -7,13 +7,10 @@ from __future__ import print_function import os import sys -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os from portage.output import EOutput from textwrap import wrap diff --git a/bin/glsa-check b/bin/glsa-check index a840c3206..eddc9050e 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -1,18 +1,15 @@ #!/usr/bin/python -# Copyright 2008-2011 Gentoo Foundation +# Copyright 2008-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function import sys -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os from portage.output import * diff --git a/bin/portageq b/bin/portageq index eeea277cc..849a86620 100755 --- a/bin/portageq +++ b/bin/portageq @@ -34,13 +34,8 @@ if os.environ.get("SANDBOX_ON") == "1": ":".join(filter(None, sandbox_write)) del sandbox_write -try: - import portage -except ImportError: - sys.path.insert(0, pym_path) - import portage -del pym_path - +sys.path.insert(0, pym_path) +import portage from portage import os from portage.eapi import eapi_has_repo_deps from portage.util import writemsg, writemsg_stdout diff --git a/bin/quickpkg b/bin/quickpkg index 76259c5c1..a6439e282 100755 --- a/bin/quickpkg +++ b/bin/quickpkg @@ -11,13 +11,10 @@ import signal import sys import tarfile -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os from portage import xpak from portage.dbapi.dep_expand import dep_expand diff --git a/bin/regenworld b/bin/regenworld index 3199fdf90..a2833445a 100755 --- a/bin/regenworld +++ b/bin/regenworld @@ -1,17 +1,14 @@ #!/usr/bin/python -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function import sys -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage from portage import os from portage._sets.files import StaticFileSet, WorldSelectedSet diff --git a/bin/repoman b/bin/repoman index dd065c8d6..d7c69b32f 100755 --- a/bin/repoman +++ b/bin/repoman @@ -33,12 +33,10 @@ except ImportError: from itertools import chain from stat import S_ISDIR -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage portage._disable_legacy_globals() portage.dep._internal_warnings = True -- 2.26.2