0

I'm trying to compile python 2.7.9 on a Sparc Solaris 10 machine. I've managed to successfully install it, except for _ssl:

Python build finished, but the necessary bits to build these modules were not found:
_bsddb             _ssl               _tkinter
bsddb185           gdbm               linuxaudiodev
ossaudiodev

OpenSSL is installed, and the libs and includes are here:

libs here: /usr/sfw/lib and includes here: /usr/sfw/include/openssl

The libs are:

lrwxrwxrwx   1 root     root          17 May 16  2014 libssl.so -> ./libssl.so.0.9.7
-rwxr-xr-x   1 root     bin      1424312 Jun 27  2013 libssl.so.0.9.7
-rwxr-xr-x   1 root     bin       151540 Jun 27  2013 libssl_extra.so.0.9.7
-rw-r--r--   1 root     bin          293 Jan 22  2005 llib-lssl
-rw-r--r--   1 root     bin       279739 Jun 21  2013 llib-lssl.ln

So, after some research it appears that python only checks for the existence of the libs in the standard paths:

e.g. /usr/local/ssl/lib & /usr/local/ssl/include

The process to resolve it is to (I believe) edit setup.py in the source tree and add the paths to these sections like:

    ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
                                 ['/usr/sfw/lib',
                                  '/usr/local/ssl/lib',
                                  '/usr/contrib/ssl/lib/'
                                 ] )

...and...

    search_for_ssl_incs_in = [
                          '/usr/sfw/include/openssl',
                          '/usr/local/ssl/include',
                          '/usr/contrib/ssl/include/'
                         ]

I am cleaning, then running this configure again:

./configure --prefix=/opt/python-2.7.9 --enable-shared

...then re-compiling using dmake.

It is still unable to find the libs. Is my method for working-around this correct?

Much appreciated.

2 Answers2

1

In addition to Joey Wilhelm's response,

If you are compiling python 2.7.9 or any other version (like me on python 2.7.12).

Certain required dependencies should be present your machine :

  • In case of ubuntu :

    apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y

the above command downloads required dependencies

  1. In case of Solaris :
  2. Equivalent dependencies should be present on your machine. If they are not present, use the below link to download. (Make sure internet access is available)

    /usr/sbin/pkgadd -d http://get.opencsw.org/now /opt/csw/bin/pkgutil -U

  3. Load all dependencies which are present for (https://www.opencsw.org/package/python/) and other dependencies as mentioned above for ubuntu. These packages are available on (https://www.opencsw.org/get-it/packages/)

  4. For openssl it is required that libssl.so should be available on path, if you do not have it you can install openssl at custom location.

    My Custom Location for extra installation : /tmp/local

    (You can also use standard /usr/local, but for me those locations are readonly)

    curl https://www.openssl.org/source/openssl-1.0.2l.tar.gz | tar xz && cd openssl-1.0.2l && ./config shared --prefix=/tmp/local/ && make && make install

    • If you already have zlib (data compression) no need for below mentioned step, else follow :

Download zlib from https://zlib.net/fossils/zlib-1.2.11.tar.gz

    tar -xvf zlib-1.2.11.tar.gz
    cd zlib-1.2.11
    ./configure --prefix=/tmp/local
    make
    make install
  • These dependencies should be present under appropriate path for the compiler at runtime :

Python install script

    export LDFLAGS="-L/tmp/local/lib/ -L/usr/local/lib/"

    # Path /opt/csw/lib/ makes sure that required libraries that we downloaded are available to the compiler
    export LD_LIBRARY_PATH="/tmp/local/lib/:/opt/csw/lib/:/usr/local/lib/"
    export CPPFLAGS="-I/tmp/local/include -I/tmp/local/include/openssl"
    export CFLAGS="-I/tmp/local/include -I/tmp/local/include/openssl"

    wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz | tar xzf Python-2.7.12.tgz && cd Python-2.7.12 
    ./configure --prefix=/tmp/python/ 
    make install
  • Finally your python build would be available at /tmp/python (appropriate path can be chosen)

Default build will be 32bit python. Incase if you wish to build 64bit python you need to import corresponding 64bit libraries and keep them in path.

Note :

Important path's for 64 bit python build generation are

/opt/csw/lib/sparcv9

/opt/csw/lib/64

Setting of -m64 bit is also important in the flags

If you have /usr/sfw/lib/libssl.so file you would not need to build a custom openssl you can add /usr/sfw/lib/ and /usr/sfw/include path in the flags.

Make sure you build openssl with command :

cd openssl-1.0.1e
./Configure solaris64-sparcv9-cc --prefix=<path> shared
make
make install

To verify 64 bit python install :

Python 2.7.12 (default, Jun 6 2017, 08:34:21)

GCC 4.5.2] on sunos5

import platform

platform.architecture()

('64bit', 'ELF')

Arjun Upadhyay
  • 334
  • 2
  • 5
0

It turns out, the solution to this is not quite so simple. It's actually two parts. The first is that your Python build is not looking for the SSL headers and libraries in the appropriate locations. That part, I was able to solve with the environment variables provided here: How do I compile Python 3.4 with custom OpenSSL?

The second part is that Python no longer supports OpenSSL < 0.9.8. So, you're going to have to upgrade to a newer version. It does appear, however, that Sunfreeware provides OpenSSL 1.0.1h, and unixpackages.com provides OpenSSL 1.0.2a, so those appear to be the way to go.

Community
  • 1
  • 1
Joey Wilhelm
  • 5,729
  • 1
  • 28
  • 42