[PATCH] Fix execution of when executing via "python -m xxx meld"
- From: Peter Tyser <ptyser gmail com>
- To: meld-list gnome org
- Subject: [PATCH] Fix execution of when executing via "python -m xxx meld"
- Date: Wed, 11 Apr 2012 01:48:08 -0500
Previously Meld would fail if python was invoked with other modules
called out on the command line. For example if using the "trace"
module:
$ python -m trace -l /home/user/meld/bin/meld fileA.txt fileB.txt
Traceback (most recent call last):
File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
File "/usr/lib/python2.6/trace.py", line 813, in <module>
main()
File "/usr/lib/python2.6/trace.py", line 801, in main
t.run('execfile(%r)' % (progname,))
File "/usr/lib/python2.6/trace.py", line 498, in run
exec cmd in dict, dict
File "<string>", line 1, in <module>
File "/tmp/meld/bin/meld", line 66, in <module>
import meld.paths
ImportError: No module named meld.paths
bin/meld previously used the "__file__" variable to find out where the
meld source was located. However when using the "-m" parameter to
Python, the "__file__" variable would point to Python's module loader
"runpy" which resulted in the above error. Using argv[0] to determine
Meld's location should be more flexible and fixes the error.
Signed-off-by: Peter Tyser <ptyser gmail com>
---
Comments are welcome. Google research didn't turn up a definitive
answer, so I'm not sure this is the most elegant solution.
bin/meld | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/bin/meld b/bin/meld
index 71e9d43..224a9ad 100755
--- a/bin/meld
+++ b/bin/meld
@@ -54,7 +54,7 @@ except ValueError:
profiling = False
# Support running from an uninstalled version
-melddir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
+melddir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), ".."))
if os.path.exists(os.path.join(melddir, "meld.doap")):
sys.path[0:0] = [melddir]
else:
--
1.7.7.431.g89633
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]