Skip to content

Commit

Permalink
Merge pull request #1701 from davemfish/bugfix/1643-gdal-dll
Browse files Browse the repository at this point in the history
Bugfix for gdal ImportErrors observed on Windows
  • Loading branch information
phargogh authored Dec 4, 2024
2 parents 7c1a196 + ecb8bf0 commit 4044ae2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ Unreleased Changes
* Updated translations for Spanish and Chinese
* natcap.invest now works with (and requires) ``gdal.UseExceptions``. A
``FutureWarning`` is raised on import if GDAL exceptions are not enabled.
* Fixed an issue on Windows where GDAL fails to find its DLLs due to
an interfering GDAL installation on the PATH, such as from anaconda.
https://github.com/natcap/invest/issues/1643
* Workbench
* Several small updates to the model input form UI to improve usability
and visual consistency (https://github.com/natcap/invest/issues/912).
Expand Down
13 changes: 8 additions & 5 deletions exe/hooks/rthook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
os.environ['PROJ_LIB'] = os.path.join(sys._MEIPASS, 'proj')

if platform.system() == 'Darwin':
# This allows Qt 5.13+ to start on Big Sur.
# See https://bugreports.qt.io/browse/QTBUG-87014
# and https://github.com/natcap/invest/issues/384
os.environ['QT_MAC_WANTS_LAYER'] = '1'

# Rtree will look in this directory first for libspatialindex_c.dylib.
# In response to issues with github mac binary builds:
# https://github.com/natcap/invest/issues/594
# sys._MEIPASS is the path to where the pyinstaller entrypoint bundle
# lives. See the pyinstaller docs for more details.
os.environ['SPATIALINDEX_C_LIBRARY'] = sys._MEIPASS

if platform.system() == 'Windows':
# sys._MEIPASS contains gdal DLLs. It does not otherwise end
# up on the PATH, which means that gdal can discover
# incompatible DLLs from some other place on the PATH, such
# as an anaconda gdal installation.
if 'PATH' in os.environ:
os.environ['PATH'] = f"{sys._MEIPASS};{os.environ['PATH']}"

0 comments on commit 4044ae2

Please sign in to comment.