_gdal_array import error when bundled with pyinstaller

Description

The change described in the following ticket #6801 causes an import error when bundled with the tool pyinstaller. Pyinstaller allows a user to bundle a python script and all of its dependencies in to a single directory or installer.

From what I can tell the import referenced in #6801 is redundant given the swig import helper stuff on the top of the gdal_array.py module. If I switch the import back to "import _gdal_array", my bundled pyinstaller package works. If I remove that import line, it also works. None of the other GDAL SWIG modules (_gdalconst.so, _gdal.so, _ogr.so, etc) seem to have this issue since they don't have the repeated import in the middle of the module.

I can see why the "from . import _gdal_array" is the correct way of importing something from the current subpackage (osgeo) and I'm not super familiar with standard practice with SWIG so I can understand a "no fix" on this. I do have a workaround I can implement for pyinstaller, but the only reason it seems to be needed is because gdal_array.py does its import differently than other SWIG modules.

Oldest firstNewest firstThreaded

Show commentsShow property changes

Change History (5)

I should add that through normal use of the osgeo/gdal package (no pyinstaller) I don't get any errors with any of the 3 forms of importing (import _gdal_array, from . import _gdal_array, or no import). That's on mac with python 3.6.