Use realpath(__file__) to locate whole portage.
authorZac Medico <zmedico@gentoo.org>
Thu, 21 Mar 2013 20:31:14 +0000 (13:31 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 21 Mar 2013 20:31:14 +0000 (13:31 -0700)
Use realpath(__file__) so that python module symlinks in site-packages
are followed back to the real location of the whole portage
installation.

pym/portage/const.py
pym/portage/tests/bin/setup_env.py
pym/portage/tests/runTests

index fdd33e63c3ac019d3320356056b186ebb51af56e..93556a02b115b289af0e33358ef1662348e849de 100644 (file)
@@ -58,7 +58,9 @@ DEPCACHE_PATH            = "/var/cache/edb/dep"
 GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
 
 # these variables are not used with target_root or config_root
-PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(__file__.split(os.sep)[:-3]))
+# NOTE: Use realpath(__file__) so that python module symlinks in site-packages
+# are followed back to the real location of the whole portage installation.
+PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__).split(os.sep)[:-3]))
 PORTAGE_BIN_PATH         = PORTAGE_BASE_PATH + "/bin"
 PORTAGE_PYM_PATH         = PORTAGE_BASE_PATH + "/pym"
 LOCALE_DATA_PATH         = PORTAGE_BASE_PATH + "/locale"  # FIXME: not used
index 1f8554e426aa73511285d5dff59081a2eec51157..42a0e56760426d276eb3857901d7a1e7b88292e4 100644 (file)
@@ -1,19 +1,17 @@
 # setup_env.py -- Make sure bin subdir has sane env for testing
-# Copyright 2007-2011 Gentoo Foundation
+# Copyright 2007-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import tempfile
 
 from portage import os
 from portage import shutil
+from portage.const import PORTAGE_BIN_PATH
+from portage.const import PORTAGE_PYM_PATH
 from portage.tests import TestCase
 from portage.process import spawn
 
-basepath = os.path.join(os.path.dirname(os.path.dirname(
-       os.path.abspath(__file__))),
-       "..", "..", "..")
-bindir = os.path.join(basepath, "bin")
-pymdir = os.path.join(basepath, "pym")
+bindir = PORTAGE_BIN_PATH
 basedir = None
 env = None
 
@@ -37,7 +35,7 @@ def binTestsInit():
        env["PF"] = "portage-tests-0.09-r1"
        env["PATH"] = bindir + ":" + os.environ["PATH"]
        env["PORTAGE_BIN_PATH"] = bindir
-       env["PORTAGE_PYM_PATH"] = pymdir
+       env["PORTAGE_PYM_PATH"] = PORTAGE_PYM_PATH
        env["PORTAGE_INST_UID"] = str(os.getuid())
        env["PORTAGE_INST_GID"] = str(os.getgid())
        env["DESTTREE"] = "/usr"
index b0069698b390c1838bc09ace2a2b3ef05e06aeab..60bcf31b70ad056857299bc1c8ae5b115f80baa6 100755 (executable)
@@ -29,7 +29,7 @@ os.environ["PORTAGE_GRPNAME"] = grp.getgrgid(os.getgid()).gr_name
 
 # Insert our parent dir so we can do shiny import "tests"
 # This line courtesy of Marienz and Pkgcore ;)
-sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.abspath(__file__)))))
+sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__)))))
 
 import portage
 portage._internal_caller = True