Commit bafe7db3 authored by Kai Willadsen's avatar Kai Willadsen

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.
parent 5458b129
......@@ -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__)
# 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]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment