Closed edmorley closed 3 years ago
Ah with this change it then works on Python 2.7:
$ h run bash
Running bash on ⬢ dry-beyond-57098... up, run.8608 (Free)
~ $ python -c 'from ctypes.util import find_library; print(find_library("gdal"))'
None
~ $ echo $LIBRARY_PATH
/app/.heroku/vendor/lib:/app/.heroku/python/lib:
~ $ export LIBRARY_PATH="/app/.heroku/vendor/lib:/app/.heroku/python/lib:/app/.heroku-geo-buildpack/vendor/lib:"
~ $ python -c 'from ctypes.util import find_library; print(find_library("gdal"))'
libgdal.so.20
Looks like adding .heroku-geo-buildpack/vendor/lib
to LIBRARY_PATH
(and not just LD_LIBRARY_PATH
) will fix this.
(Checking the legacy feature, it adds to both too.)
With the legacy Python buildpack
BUILD_WITH_GEO_LIBRARIES
feature, the GDAL library that was vendored was auto-detectable by Django, without the need to setGDAL_LIBRARY_PATH
in the Django settings file.Django's auto-detection is here: https://github.com/django/django/blob/f63f3cdf0969c23fd0c05de0f4a2a1df0cd5112e/django/contrib/gis/gdal/libgdal.py#L13-L47
But in short it does the equivalent of:
Trying this using the legacy feature works:
However using this buildpack it doesn't:
Interestingly, if I change the Python version from 2.7 to 3.6, it does work.
Looking at https://docs.python.org/3/library/ctypes.html#finding-shared-libraries I see: