Skip to content

Commit

Permalink
[processing] Prioritze bundled gdal over framework on OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Jun 16, 2014
1 parent 7ed87c6 commit 09cfc03
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

import os
import subprocess
import platform
from PyQt4.QtCore import *
from qgis.core import QgsApplication
from processing.core.ProcessingLog import ProcessingLog

try:
Expand All @@ -43,12 +45,27 @@ class GdalUtils:

@staticmethod
def runGdal(commands, progress):
settings = QSettings()
path = unicode(settings.value('/GdalTools/gdalPath', ''))
envval = unicode(os.getenv('PATH'))
if not path.lower() in envval.lower().split(os.pathsep):
envval += '%s%s' % (os.pathsep, path)
os.putenv('PATH', envval)
# We need to give some extra hints to get things picked up on OS X
if platform.system() == 'Darwin':
if os.path.isfile(os.path.join(QgsApplication.prefixPath(), "bin", "gdalinfo")):
# Looks like there's a bundled gdal. Let's use it.
os.environ['PATH'] = "%s%s%s" % (os.path.join(QgsApplication.prefixPath(), "bin"), os.pathsep, envval)
os.environ['DYLD_LIBRARY_PATH'] = os.path.join(QgsApplication.prefixPath(), "lib")
else:
# Nothing internal. Let's see if we can find it elsewhere.
settings = QSettings()
path = unicode(settings.value('/GdalTools/gdalPath', ''))
envval += '%s%s' % (os.pathsep, path)
os.putenv('PATH', envval)
else:
# Other platforms should use default gdal finder codepath
settings = QSettings()
path = unicode(settings.value('/GdalTools/gdalPath', ''))
if not path.lower() in envval.lower().split(os.pathsep):
envval += '%s%s' % (os.pathsep, path)
os.putenv('PATH', envval)

loglines = []
loglines.append('GDAL execution console output')
fused_command = ''.join(['%s ' % c for c in commands])
Expand Down Expand Up @@ -127,4 +144,4 @@ def escapeAndJoin(strList):
else:
escaped = s
joined += escaped + ' '
return joined.strip()
return joined.strip()

0 comments on commit 09cfc03

Please sign in to comment.