Unable to build python3 container with pyldap requirement

Latest response

Base image is python:3

Requirements.txt:

Django==2.0.2
django-auth-ldap==1.3.0
django-bootstrap3==9.1.0
django-crispy-forms==1.7.0
django-extensions==2.0.0
django-filter==1.1.0
djangorestframework==3.7.7
Markdown==2.6.11
psycopg2==2.7.4
psycopg2-binary==2.7.4
pyldap==2.4.45
pytz==2018.3
six==1.11.0
typing==3.6.4

Getting this error when I build the image:

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.45 -IModules -I/usr/include -I/usr/include/sasl -I/usr/local/include -I/usr/local/include/sasl -I/usr/local/include/python3.6m -c Modules/LDAPObject.c -o build/temp.linux-x86_64-3.6/Modules/LDAPObject.o
In file included from Modules/LDAPObject.c:8:0:
Modules/errors.h:7:18: fatal error: lber.h: No such file or directory
#include "lber.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1

yum is not installed on base image so I can't add a RUN statement to install the dependency lber.h. Any ideas how to get around this?

Responses

David,

One issue is that the following package is deprecated and has been replaced by python-ldap:

pyldap==2.4.45

Deprecation message is here:
https://github.com/pyldap/pyldap

The real issue looks to be that they don't ship a compiled version of the package so you need the build tools and required libraries to build in the container. One option is to build outside the container and copy it in.. or manually copy in build requirements (not really what you want in your final production container).

I assume requirements are being pulled from pypi directly? Another option is to configure a local repository and have compiled versions of packages available there for the container builds.

I would probably need more details to troubleshoot much further sorry.

-edit-

If you wanted to still use yum to install the deps, you could potentially use buildah to mount the image then use yum with the install root option with the mounted container path:

yum --installroot

-edit 2-
Another option is to contact the author and ask if they can distribute this package as a wheel, which would remove the compilation requirement (they may have reasons for not doing this).
https://pythonwheels.com/

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.