Use realpath(__file__) to locate whole portage.

Use realpath(__file__) so that python module symlinks in site-packages
are followed back to the real location of the whole portage
installation.
diff --git a/pym/portage/const.py b/pym/portage/const.py
index fdd33e6..93556a0 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -58,7 +58,9 @@
 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
diff --git a/pym/portage/tests/bin/setup_env.py b/pym/portage/tests/bin/setup_env.py
index 1f8554e..42a0e56 100644
--- a/pym/portage/tests/bin/setup_env.py
+++ b/pym/portage/tests/bin/setup_env.py
@@ -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 @@
 	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"
diff --git a/pym/portage/tests/runTests b/pym/portage/tests/runTests
index b006969..60bcf31 100755
--- a/pym/portage/tests/runTests
+++ b/pym/portage/tests/runTests
@@ -29,7 +29,7 @@
 
 # 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