I need to install several Python modules on a RHEL where I don't have root access. At least one of the modules also needs access to Python.h
.
In this case I find that the best thing is to install python and it dependencies in ~/local
. It usually just works, but this time Python fails to build the SSL module (see details below). Here's the trace of what I'm doing.
So I downloaded python 6 source and off I went:
./configure --prefix=/home/fds/rms/local
make >& make.log
An inspection to log reveals that ssl module has not been compiled, but there is no mention of the cause (no other occurence of ssl in make or configure):
Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_hashlib _sqlite3 _ssl <----------
So I figure, python is not finding any ssl library at all (which is strange, but hey...). So I download openssl-0.9.8r and
./config --prefix=/home/fds/rms/local shared
make
make install
Now back to Python, I ./configure and make again. It fails, but this time it's different:
Failed to build these modules:
_hashlib _ssl
A closer inspection to the log file reveals this:
gcc -pthread -shared build/temp.linux-x86_64-2.6/home/fds/rms/installers/Python-2.6.6/Modules/_ssl.o -L/home/fds/rms/local/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.6/_ssl.so
*** WARNING: renaming "_ssl" since importing it failed: libssl.so.0.9.8: cannot open shared object file: No such file or directory
So now it's picking up the library but not quite getting it right (the file is there where is should be):
$ find /home/fds/rms/local -iname libssl.so.0.9.8
/home/fds/rms/local/lib/libssl.so.0.9.8
Next thing is tracing make and see where is it looking for the file:
$ strace -f make 2>&1 | grep libssl.so.0.9.8
[pid 5584] open("/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/tls/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/tls/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/tls/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/tls/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] write(1, "*** WARNING: renaming \"_ssl\" sin"..., 131*** WARNING: renaming "_ssl" since importing it failed: libssl.so.0.9.8: cannot open shared object file: No such file or directory
[pid 5584] open("/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/tls/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] write(1, "*** WARNING: renaming \"_hashlib\""..., 135*** WARNING: renaming "_hashlib" since importing it failed: libssl.so.0.9.8: cannot open shared object file: No such file or directory
Mhhh, it's looking in all the wrong places. I try to give a hint:
CPPFLAGS="-I/home/fds/rms/local/include -I/home/fds/rms/local/include/openssl" LDFLAGS="-L/home/fds/rms/local/lib" ./configure --prefix=/home/fds/rms/local
But nothing changes, and make
does not seem to try /home/fds/rms/local/lib
at all.
I haven't done this in years, so maybe I'm overlooking something. Can anyone help with the problem?
Thanks in advance.
For MAC OS HIGH Sierra, and Python-3.5.6 install openssl using brew
This will install openssl at /usr/local/Cellar/openssl/1.0.2o_2/ this path needs to be updated in Modules/Setup.dist at
In the above lines update SSL value to
and uncomment the lines, do a CMM and your python will get compiled with openssl.
You need to edit
Modules/Setup.dist
to specify the location of OpenSSL if it is not in the standard location. From Getting SSL Support in Python 2.5.1:Make sure the changes to
Modules/Setup.dist
get picked up by cleaning the source root (e.g.make distclean
) and runconfigure
andmake
again.I'm building Python2.7.13 and I see this same issue. For 2.7.13 you have to use "openssl1.0.0e" or above to make it work. I tried openssl-0.9.8g and it doesn't work. And somehow I can't make it work just modifying Modules/Setup.dist so I have to manually compile that _ssl.o. I guess this is because openssl-0.9.8g I provided is not working and it searched for system default libssl.so.10 which doesn't work either.
For me editing
Modules/Setup
was not enough as_hashlib
module still ended up using the wrong OpenSSL version; andLD_LIBRARY_PATH
was not taken into account at runtime on my SLES system.What worked was to statically link the local OpenSSL to both
_ssl
and_hashlib
by editingsetup.py
as per GitHub patch: eddy-geek/ python_custom_openssl.diff, and thenmake clean && make
.More details on why I used static links on Stack Overflow at Coredump when compiling python with a custom openssl version.
the simple way to keep track is to install a standalone version of pkgconfig into your portable location. Then add PATH=/your/path:$PATH:/your/path (*will varry with endianess). you will not grab everything from that dir without any cflags, ldflags, include or lib flags plus it is easy to switch back and forth by toggling path.
I have a set of a couple of patches for static openssl and static libintl for 2 and 3 below.
For openssl (first patch) you have to set the env var OPENSSL_ROOT.
This is based on the patch from http://gist.github.com/eddy-geek/9604982 .
For Python 2.7.14:
https://gist.github.com/rkitover/2d9e5baff1f1cc4f2618dee53083bd35
https://gist.github.com/rkitover/afab7ed3ac7ce1860c43a258571c8ae1
For Python 3.6.3:
https://gist.github.com/rkitover/93d89a679705875c59275fb0a8f22b45
https://gist.github.com/rkitover/b18f19eafda3775a9652cc9cdf3ec914