Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doc building: import GDAL Python bindings early
We don't strictly need to import them at the beginning of conf.py, but importing them early helps in having a better error message if they cannot be imported rather than waiting later when autodoc tries to load them In my case, this was due to an obscure situation. My libgdal.so in my build tree links to a /path/to/install-libjpeg-turbo/lib/libjpeg.so.8, with it being libjpeg-turbo 3.0 with new symbols. That full path to libjpeg is embedded in libgdal.so, but /path/to/install-libjpeg-turbo/lib was not pointed in LD_LIBRARY_PATH. This worked fine when doing "from osgeo import gdal" from a 'regular' Python interpreter, or running pytest. But strangely, this failed within the sphinx-build process. The autodoc error message wasn't helpful just saying it couldn't import the osgeo module, whereas if trying to import in conf.py I got an exception pointing to the fact a symbol from libjpeg.so couldn't be loaded. I suspect that something in the sphinx-build process loads the system libjpeg library, that does not have the new symbols of libjpeg-turbo 3.0 that my libgdal.so was using, hence causing later loading of libgdal to fail. Now that I've added /path/to/install-libjpeg-turbo/lib in LD_LIBRARY_PATH, things work and this patch isn't actually needed, but it may help diagnose further similar situations
- Loading branch information