[BACKPORT] find python on OSX (partially fix #3097)

don't overwrite PATH env var, but append to it.
This commit is contained in:
Giuseppe Sucameli 2011-12-01 01:47:19 +01:00
parent 5193f60d2a
commit 99edf1de05
2 changed files with 16 additions and 7 deletions

View File

@ -760,3 +760,9 @@ class Version:
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] )

View File

@ -24,16 +24,19 @@ class GdalToolsBaseDialog(QDialog, Ui_Dialog):
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)