heroku / heroku-geo-buildpack

0 stars 2 forks source link

Set LIBRARY_PATH at runtime too #17

Closed edmorley closed 3 years ago

edmorley commented 3 years ago

Django's library location auto-detection relies upon the stdlib's ctypes.util.find_library(), which in Python versions earlier than Python 3.6, didn't check LD_LIBRARY_PATH, only LIBRARY_PATH: https://docs.python.org/3/library/ctypes.html#finding-shared-libraries

Setting LIBRARY_PATH at runtime increases parity with the Python buildpack's legacy feature: https://github.com/heroku/heroku-buildpack-python/blob/41f657fbff4dd90efa7705737bc6fee4fba05dba/bin/steps/geo-libs#L53-L57

And makes auto-detection work on Python <3.6.

Fixes #16. Closes W-8391584.

edmorley commented 3 years ago

Using this branch:

$ mkdir testapp-geo-buildpack-fix && cd $_ && git init && h create --stack heroku-18
$ h buildpacks:add https://github.com/heroku/heroku-geo-buildpack#edmorley-set-library-path
$ h buildpacks:add heroku/python
$ echo 'python-2.7.16' > runtime.txt
$ touch requirements.txt
$ git add -A; git commit -m '.' && git push heroku main
...
$ h run -- python -c 'from ctypes.util import find_library; print(find_library("gdal"))'
libgdal.so.20
KevinBrolly commented 3 years ago

Nicely spotted @edmorley! Many thanks.