Rely on PYTHONPATH instead of PORTAGE_PYM_PATH for locating portage's python modules...
authorZac Medico <zmedico@gentoo.org>
Tue, 31 Oct 2006 04:23:06 +0000 (04:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 31 Oct 2006 04:23:06 +0000 (04:23 -0000)
svn path=/main/trunk/; revision=4884

17 files changed:
NEWS
bin/archive-conf
bin/chkcontents
bin/clean_locks
bin/dispatch-conf
bin/ebuild
bin/emaint
bin/emerge
bin/env-update
bin/fix-db.py
bin/fixpackages
bin/md5check.py
bin/pkgname
bin/portageq
bin/regenworld
bin/repoman
bin/xpak

diff --git a/NEWS b/NEWS
index 64cd1da6a5ea3be6e8a39824d1dfd77d1f8fa31c..7f0bc40cce170246553b4006decab1be368e092b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,7 +19,7 @@ portage-2.1.2
   order and detection of circular dependencies.
 * The world and system sets allow automatic update of all installed slots.
 * DEPEND atoms support SLOT dependencies of the form ${CATEGORY}/${PN}:${SLOT}.
-* Development: Extend PORTAGE_PYM_PATH support to allow overriding the hardcoded 
+* Development: Extend PYTHONPATH support to allow overriding the hardcoded 
   /usr/lib/portage/pym for development/testing purposes
 
 portage-2.1.1
index 0417e97cc293e245739498e58ec04d0e6c73bc26..b3d17cc6f692100b970c0cb85cef998178c757dc 100755 (executable)
 #
 
 import os, sys, string
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
+try:
+    import portage
+except ImportError:
+    sys.path.insert(0, "/usr/lib/portage/pym")
+    import portage
 
-import portage, dispatch_conf
+import dispatch_conf
 
 FIND_EXTANT_CONTENTS  = "find %s -name CONTENTS"
 
index 4523b63064b041370ec7d247e50b02776904511c..aae45c6bcc91a2f46dd3d6aba6e52d74eca8f136 100755 (executable)
@@ -9,8 +9,11 @@
 # the right files).
 
 import string, os.path, os, sys
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-import portage
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 
 def CONTENTScheck(path):
        try:
index 9c7e110ce472a9fdc10fd00af1f5e326dda4950c..71db0b8e216addcc58f4dbbbdd9de627c218003d 100755 (executable)
@@ -4,9 +4,11 @@
 # $Id$
 
 import os,sys,errno
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-
-import portage_locks
+try:
+       import portage_locks
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage_locks
 
 if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv:
        import portage
index 277d6ef4bef7cab52dc0ce6f6e2dcc1ef444d709..2309b680fe18a6df751cf8b02996bdebc74b007f 100755 (executable)
 from stat import *
 from random import *
 import atexit, commands, os, re, shutil, stat, string, sys
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
+try:
+    import portage
+except ImportError:
+    sys.path.insert(0, "/usr/lib/portage/pym")
+    import portage
 
-import portage, dispatch_conf
+import dispatch_conf
 from portage_exec import find_binary
 
 FIND_EXTANT_CONFIGS  = "find '%s' %s -iname '._cfg????_%s'"
index 2d8c0890e83ae68de493b0e179d88bedbf8cdb81..da405db07be1c30029ec46943301a4f1a69d5028 100755 (executable)
@@ -21,9 +21,13 @@ if "merge" in pargs:
        os.environ["FEATURES"] = os.environ.get("FEATURES", "") + " -noauto"
 
 os.environ["PORTAGE_CALLER"]="ebuild"
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 
-import portage, portage_util, portage_const
+import portage_util, portage_const
 
 # do this _after_ 'import portage' to prevent unnecessary tracing
 if debug and "python-trace" in portage.features:
index 016c64ea4d8ffd6633ddb13478105757c2a868ae..bff6856f807e73ee5a3967a552564fd411437e0b 100755 (executable)
@@ -1,12 +1,16 @@
 #!/usr/bin/python -O
 
 import sys, os
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
 from optparse import OptionParser, OptionValueError
 
 import re
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 
-import os, portage, portage_const, portage_exception
+import portage_const, portage_exception
 class WorldHandler(object):
 
        def name():
index 933b461d07a5c23b6ea27a8920d4579a4716046a..959224a12ad90c413f1a8aa6d99244793930650c 100755 (executable)
@@ -21,10 +21,13 @@ except KeyboardInterrupt:
        sys.exit(1)
 
 import os, stat
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
 
 os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
-import portage
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 del os.environ["PORTAGE_LEGACY_GLOBALS"]
 from portage import digraph
 
index 1026b1fc10ad237aed454a6b8a79bf44963953c3..b245b39905d8f5438d19ae0e08b8da7c868e57b3 100755 (executable)
@@ -4,7 +4,6 @@
 # $Id$
 
 import os,sys
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
 
 def usage(status):
        print "Usage: env-update [--no-ldconfig]"
@@ -24,5 +23,9 @@ if len(sys.argv) > 1:
        print "!!! Invalid command line options!\n"
        usage(1)
 
-import portage
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 portage.env_update(makelinks)
index fef1a4d443bcb79af9c621d34536da9c5a395b6f..e8bbad2caff2803d82bfe5dab3ea6e2e2feba3f6 100755 (executable)
@@ -4,7 +4,12 @@
 # $Id$
 
 import os,sys,re
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
+
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 
 from stat import *
 from output import *
index f9d09dec2bd896a052d6c25030569800c7badaca..f7c1bf51d4d3e665881dd05dc89fe10b3d191ec9 100755 (executable)
@@ -5,9 +5,11 @@
 
 import os,sys
 os.environ["PORTAGE_CALLER"]="fixpackages"
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-
-import portage
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 
 mysettings = portage.settings
 mytrees = portage.db
index 98f3c81077fa74077f63c619a74e4f536ef91af6..c83331ede426f7350667e08153bb6effa4f57c0d 100755 (executable)
@@ -5,9 +5,11 @@
 
 import os,sys,string
 os.environ["FEATURES"]="mirror cvs"
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-
-import portage
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 from threading import *
 from output import red,green,blue,bold
 from random import shuffle
index 546b05d3c97aa02e654694bdd1e0b430876772b2..ee4807744c0ddaf0e1d4718851dfa495cb7bbaf2 100755 (executable)
@@ -4,9 +4,11 @@
 # $Id$
 
 import sys, os
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-
-import portage
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 
 a=portage.pkgsplit(sys.argv[1])
 if a:
index 0424647b75c50b72aff603200cff7b25c454c28c..5ee16c4ec802e2d905af655000cac0963406ae1f 100755 (executable)
@@ -20,7 +20,6 @@ except KeyboardInterrupt:
        sys.exit(1)
 
 import os
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
 
 import types,string
 
@@ -332,7 +331,11 @@ def main():
                if uses_root:
                        os.environ["ROOT"] = sys.argv[2]
                global portage
-               import portage
+               try:
+                       import portage
+               except ImportError:
+                       sys.path.insert(0, "/usr/lib/portage/pym")
+                       import portage
                if uses_root:
                        sys.argv[2] = portage.root
                function(sys.argv[2:])
index d5e28dd7f34e76872279db3e05a96d6d33ed0ae4..a7428ed9e1d6472e6f5510e53dd1004b8271bb25 100755 (executable)
@@ -4,8 +4,12 @@
 # $Id$
 
 import sys, os
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
-import portage, string, re
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
+import string, re
 
 __candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* emerge ")
 __noncandidatematcher__ = re.compile(" sync( |$)| clean( |$)| search( |$)|--oneshot|--fetchonly| unmerge( |$)")
index c05ae9e404b24896242510d839122d47415b0e2d..4e8f7fc14803b57ba7ba306f3a7f11d84f4e2559 100755 (executable)
@@ -11,7 +11,6 @@ import errno, os, shutil, sys
 if not hasattr(__builtins__, "set"):
        from sets import Set as set
 exename=os.path.basename(sys.argv[0])  
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
 version="1.2"  
 
 allowed_filename_chars="a-zA-Z0-9._-+:"
@@ -24,7 +23,11 @@ map(allowed_filename_chars_set.setdefault, map(chr, map(ord, [".", "-", "_", "+"
 import string,signal,re,pickle,tempfile
 
 os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
-import portage
+try:
+       import portage
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import portage
 del os.environ["PORTAGE_LEGACY_GLOBALS"]
 
 import portage_checksum
index 1a0743773de90535e5a189c958698ea3588fbfc4..8dcbf145c2edc7939e48566ebf84ce0caedde549 100755 (executable)
--- a/bin/xpak
+++ b/bin/xpak
@@ -8,7 +8,10 @@ if len(sys.argv)!=3:
        print "xpak: expecting three arguments."
        sys.exit(1)
 
-sys.path.insert(0, os.environ.get("PORTAGE_PYM_PATH", "/usr/lib/portage/pym"))
+try:
+       import xpak
+except ImportError:
+       sys.path.insert(0, "/usr/lib/portage/pym")
+       import xpak
 
-import xpak
 xpak.xpak(sys.argv[1],sys.argv[2])