[meld] Fix uninstalled use with modules that change __file__
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Fix uninstalled use with modules that change __file__
- Date: Fri, 27 Apr 2012 22:14:42 +0000 (UTC)
commit bafe7db31481f6cb2c2a013da5ded93affae43fe
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Apr 28 08:05:45 2012 +1000
Fix uninstalled use with modules that change __file__
Some modules such as runpy (and by extension, modules such as trace
that use runpy) alter the value of __file__, which causes our
directory-location logic to fail. This patch tries to detect this by
checking the value of __file__ and falling back to sys.argv[0] when it
looks to be dodgy.
Based on a patch and suggestions from Peter Tyser.
bin/meld | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 71e9d43..e5e8250 100755
--- a/bin/meld
+++ b/bin/meld
@@ -54,7 +54,13 @@ except ValueError:
profiling = False
# Support running from an uninstalled version
-melddir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
+if os.path.basename(__file__) == "meld":
+ self_path = os.path.realpath(__file__)
+else:
+ # Hack around an issue with some modules s.a. runpy/trace in Python <2.7
+ self_path = os.path.realpath(sys.argv[0])
+melddir = os.path.abspath(os.path.join(os.path.dirname(self_path), ".."))
+
if os.path.exists(os.path.join(melddir, "meld.doap")):
sys.path[0:0] = [melddir]
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]