How do I compile Python 3.4 with custom OpenSSL? How do I compile Python 3.4 with custom OpenSSL? python python

How do I compile Python 3.4 with custom OpenSSL?


I managed to figure it out after a lot of hair-pulling. It was a bunch of environment variables... I think I might have done a little overkill, but this basically worked:

# OpenSSL 1.0.1g./config shared --prefix=/my/path --openssldir=/my/path/opensslmakemake install# Python 3.4export LDFLAGS="-L/my/path/lib/ -L/my/path/lib64/"export LD_LIBRARY_PATH="/my/path/lib/:/my/path/lib64/"export CPPFLAGS="-I/my/path/include -I/my/path/include/openssl"./configure --prefix=/my/path/makemake install


Thanks @ScottFrazer for his answer. Saved me a lot of troubles.

Here is a script I used in ubuntu to compile python with the latest openssl 1.0.2g.

# new openssl installcurl https://www.openssl.org/source/openssl-1.0.2g.tar.gz | tar xz && cd openssl-1.0.2g && ./config shared --prefix=/usr/local/ && make && make install# Python install scriptexport LDFLAGS="-L/usr/local/lib/"export LD_LIBRARY_PATH="/usr/local/lib/"export CPPFLAGS="-I/usr/local/include -I/usr/local/include/openssl"apt-get updateapt-get install build-essential checkinstall -yapt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -ycd /home/web/wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz | tar xzf Python-2.7.11.tgz && cd Python-2.7.11 ./configure --prefix=/usr/local/ make altinstall

Notice, the install is an altinstall which means it will not override the default python on ubuntu. To verify the installation was successful:

/usr/local/bin/python2.7>>> import ssl>>> ssl.OPENSSL_VERSION'OpenSSL 1.0.2g  1 Mar 2016'


This is how I solved it in 3.4. It is applicable for 2.7 and 3.4. The important is --with-ssl config argument in the ./configure:

wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgztar -xf Python-3.4.3.tgzcd Python-3.4.3/sudo yum install gcc./configure --with-sslmake && make install# If you like to live dangerously since this will overwrite default python executablemake && make altinstall# Safer because you access your new Python using python3.4