portage.const: realpath(__file__.rstrip("co")) v2.2.0_alpha169
authorZac Medico <zmedico@gentoo.org>
Fri, 22 Mar 2013 01:42:20 +0000 (18:42 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 22 Mar 2013 01:42:20 +0000 (18:42 -0700)
With python2.x, __file__ may refer to the compiled bytcode file, but we
want to follow the symlink of the uncompile py file.

pym/portage/const.py

index 93556a02b115b289af0e33358ef1662348e849de..5e960d9687758640162a2fdbbb5773d2525f25ed 100644 (file)
@@ -60,7 +60,7 @@ GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
 # these variables are not used with target_root or config_root
 # 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_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__.rstrip("co")).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