Skip to content
Permalink
Browse files
[BACKPORT] find python on OSX (partially fix #3097)
don't overwrite PATH env var, but append to it.
  • Loading branch information
brushtyler committed Dec 1, 2011
1 parent 5193f60 commit 99edf1de05231f422c9f2f6e2110709557f62ea2
Showing with 16 additions and 7 deletions.
  1. +6 −0 python/plugins/GdalTools/tools/GdalTools_utils.py
  2. +10 −7 python/plugins/GdalTools/tools/dialogBase.py
@@ -760,3 +760,9 @@ def __cmp__(self, other):

def __str__(self):
return ".".join(self.vers)


# setup the default MacOs path
#if platform.system() == "Darwin" and getGdalPath().isEmpty():
# setGdalPath( u"/Library/Frameworks/GDAL.framework/Versions/%s/Programs" % str(GdalConfig.version())[:3] )

@@ -24,16 +24,19 @@ def __init__(self, parent, iface, pluginBase, pluginName, pluginCommand):
self.process = QProcess(self)
gdalPath = Utils.getGdalPath()
if not gdalPath.isEmpty():
sep = ";" if platform.system() == "Windows" else ":"
env = self.process.environment()
if env.isEmpty():
#env << "PATH=" + gdalPath
os.putenv( "PATH", str( gdalPath ) )
# process.enviroment() is probably not supported (MacOS?),
# use os.putenv() instead
path = os.getenv("PATH")
if path != "":
path += sep
path += gdalPath
os.putenv( "PATH", path )
else:
if platform.system() == "Windows":
env.replaceInStrings( QRegExp( "^PATH=(.*)", Qt.CaseInsensitive ), "PATH=\\1;" + gdalPath )
else:
env.replaceInStrings( QRegExp( "^PATH=(.*)", Qt.CaseInsensitive ), "PATH=\\1:" + gdalPath )
self.process.setEnvironment( env )
env.replaceInStrings( QRegExp( "^PATH=(.*)", Qt.CaseInsensitive ), "PATH=\\1%s%s" % (sep, gdalPath) )
self.process.setEnvironment( env )
self.connect(self.process, SIGNAL("error(QProcess::ProcessError)"), self.processError)
self.connect(self.process, SIGNAL("finished(int, QProcess::ExitStatus)"), self.processFinished)

0 comments on commit 99edf1d

Please sign in to comment.