python-ldap failed to install in Heroku

折月煮酒 提交于 2020-01-14 09:52:10

问题


It seems like Heroku does not support python-ldap. The pip install with "python-ldap==2.3.13" in the requirements.txt file failed with following error in Heroku:

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/local/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o

Modules/LDAPObject.c:18:18: error: sasl.h: No such file or directory

It seems like Heroku does not have the libraries required for python-ldap and I don't know if there is a way to install dependency libraries except 'pip'.

What is the recommended solution to support ldap authentications in Heroku's Python/Django stack?

Your help is greatly appreciated.


回答1:


You can create a custom build pack that vendors in any libraries you like. Take a look at https://github.com/cirlabs/heroku-buildpack-geodjango it installs a library via Curl.




回答2:


I know this question is old, but I had the same problem and Google brought me here. I'll write what I found so maybe I can help people that have the same problem and want a currently working solution.

As @Schneems said you can create your own buildpack using heroku and add your custom environment.

You can create a custom buildpack containing python-ldap, but, creating a custom buildpack from zero is not really an option for some, so you can fork the official python buildpack https://github.com/heroku/heroku-buildpack-python and add it python-ldap as @damgad did.

The problem here is that the repo from @damgad is outdated compared to the recent version of the official python/buildpack. (At the time of this comment)

I found this pull request(now closed) https://github.com/heroku/heroku-buildpack-python/pull/271 from a guy that used @damgad code and created his own fork https://github.com/josegonzalez/heroku-buildpack-python.

I tried using it, but his repo was outdated and got some errors deploying my app.

So I just created my own fork of the currently official heroku/python buildpack added it https://github.com/josegonzalez/heroku-buildpack-python. code, fixed just some errors I was getting and you have this currently working buildpack with python-ldap https://github.com/manuggz/heroku-buildpack-python.

This buildpack supports python3.6 and thats all I wanted.

Tl;dr You have to use this updated buildpack if you want to use python-ldap (or create your own forking the official buildpack):

$ heroku buildpacks:set https://github.com/manuggz/heroku-buildpack-python 



回答3:


I recelntly created heroku buildpack that supports python-ldap. It's availabale on my github repo.

To make it work you only need to specify environment variable like that:

heroku config:set BUILDPACK_URL=https://github.com/damgad/heroku-buildpack-python-ldap.git


来源:https://stackoverflow.com/questions/10509607/python-ldap-failed-to-install-in-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!