Skip to content

Commit f84697c

Browse files
committed
Merge pull request yousseb#16 from nickie/fix-rel-paths
Bug fix to make paths relative to PWD in MacOS app
2 parents 8584d37 + 2b1fa36 commit f84697c

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

osx/Meld

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
import sys
44
import os
@@ -7,23 +7,33 @@ import subprocess
77
def getScriptPath():
88
return os.path.dirname(os.path.realpath(sys.argv[0]))
99

10+
def fix_abspath(path):
11+
if not os.path.isabs(path):
12+
cwd = os.environ['PWD']
13+
path = os.path.join(cwd, path)
14+
return os.path.normpath(path)
1015

1116
arglist = []
1217
for arg in sys.argv[1:]:
1318
if arg.startswith('--output'):
1419
filename = arg.split('=')[1]
15-
newArg = '--output=' + os.path.abspath(filename)
20+
newArg = '--output=' + fix_abspath(filename)
1621
elif arg.startswith('-'):
1722
newArg = arg
1823
else:
19-
newArg = os.path.abspath(arg)
24+
newArg = fix_abspath(arg)
2025
arglist.append(newArg)
2126

22-
MELDPATH = getScriptPath() + "/Meld-bin"
23-
APPPATH = os.path.abspath(os.path.join(getScriptPath(), '..'))
27+
MELDPATH = os.path.join(getScriptPath(), "Meld-bin")
28+
APPPATH = fix_abspath(os.path.join(getScriptPath(), '..'))
2429

25-
environment = dict(os.environ,
26-
**{ "DYLD_LIBRARY_PATH" : APPPATH+"/Resources/lib:"+ APPPATH+"/Frameworks",
27-
"LANG": "C"})
30+
environment = dict(os.environ, **{
31+
"DYLD_LIBRARY_PATH": ":".join([
32+
os.path.join(APPPATH, "Resources", "lib"),
33+
os.path.join(APPPATH, "Frameworks")
34+
]),
35+
"LANG": "C"
36+
})
2837

29-
p = subprocess.call([MELDPATH] + arglist, env= environment)
38+
status = subprocess.call([MELDPATH] + arglist, env=environment)
39+
exit(status)

0 commit comments

Comments
 (0)