I want to share how i compiled from source python versions 2.4 and 2.6 on precise pangolin. These versions of python where discarded on this ubuntu release, they can be compiled from source with just few quirks.
I am not completely sure about the required libs since i tried various combinations before looking at the actual code, so any comments on those are well accepted
python 2.6.8
required libs:
Code:
apt-get build-dep python
python source download:
exctract
Code:
tar xjvf Python-2.6.8.tar.bz2
cd Python-2.6.8
create a text file setup_py.patch with any preferred text editor (vim anyone?) with the following content:
Code:
--- Python-2.6.8/setup.py 2012-04-10 17:32:11.000000000 +0200
+++ Python-2.6.8_ok/setup.py 2012-05-08 12:42:23.893052724 +0200
@@ -410,6 +410,7 @@
lib_dirs = self.compiler.library_dirs + [
'/lib64', '/usr/lib64',
'/lib', '/usr/lib',
+ '/usr/lib/x86_64-linux-gnu'
]
inc_dirs = self.compiler.include_dirs + ['/usr/include']
exts = []
apply the patch:
Code:
patch Modules/_ssl.c < _ssl.patch
create a text file ssl.patch with this content:
Code:
--- Modules/_ssl.c 2012-04-10 17:32:09.000000000 +0200
+++ Modules/_ssl.c 2012-05-08 17:50:46.929523605 +0200
@@ -302,8 +302,8 @@
self->ctx = SSL_CTX_new(TLSv1_method()); /* Set up context */
else if (proto_version == PY_SSL_VERSION_SSL3)
self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
- else if (proto_version == PY_SSL_VERSION_SSL2)
- self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
+/* else if (proto_version == PY_SSL_VERSION_SSL2)
+ self->ctx = SSL_CTX_new(SSLv2_method());*/ /* Set up context */
else if (proto_version == PY_SSL_VERSION_SSL23)
self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
PySSL_END_ALLOW_THREADS
@@ -1688,8 +1688,8 @@
PY_SSL_CERT_REQUIRED);
/* protocol versions */
- PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
- PY_SSL_VERSION_SSL2);
+/* PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
+ PY_SSL_VERSION_SSL2);*/
PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
PY_SSL_VERSION_SSL3);
PyModule_AddIntConstant(m, "PROTOCOL_SSLv23",
apply the patch:
Code:
patch Modules/_ssl.c < _ssl.patch
launch the ./configure command with the following syntax:
Code:
env CPPFLAGS="-I/usr/lib/x86_64-linux-gnu" LDFLAGS="-L/usr/include/x86_64-linux-gnu" ./configure --prefix=/opt/python2.6
be careful: the previous command will set the installation directory on /opt/python2.6. If you want to change that directory you have to change the --prefix parameter
actual compilation:
another patch file (ssl.py) to create:
Code:
--- Lib/ssl.py 2012-04-10 17:32:06.000000000 +0200
+++ Lib/ssl.py 2012-05-08 17:51:34.029522977 +0200
@@ -61,7 +61,7 @@
from _ssl import SSLError
from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
-from _ssl import PROTOCOL_SSLv2, PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
+from _ssl import PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
from _ssl import RAND_status, RAND_egd, RAND_add
from _ssl import \
SSL_ERROR_ZERO_RETURN, \
apply the patch:
Code:
patch Lib/ssl.py < ssl_py.patch
system installation:
Python 2.4.6
libs required:
Code:
apt-get build-dep python
python 2.4 source download:
Code:
tar xvjf Python-2.4.6.tar.bz2
cd Python-2.4.6
create a patch file setup_py.patch:
Code:
--- setup.py 2006-10-08 19:41:25.000000000 +0200
+++ setup.py 2012-05-08 14:02:14.325174357 +0200
@@ -269,6 +269,7 @@
lib_dirs = self.compiler.library_dirs + [
'/lib64', '/usr/lib64',
'/lib', '/usr/lib',
+ '/usr/lib/x86_64-linux-gnu'
]
inc_dirs = self.compiler.include_dirs + ['/usr/include']
exts = []
@@ -496,7 +497,8 @@
ssl_incs += krb5_h
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
['/usr/local/ssl/lib',
- '/usr/contrib/ssl/lib/'
+ '/usr/contrib/ssl/lib/',
+ 'x86_64-linux-gnu'
] )
if (ssl_incs is not None and
apply the patch1
Code:
patch setup.py < setup_py.patch
configure and set the installation directory on /opt/python2.4:
Code:
env CPPFLAGS="-I/usr/lib/x86_64-linux-gnu" LDFLAGS="-L/usr/include/x86_64-linux-gnu" ./configure --prefix=/opt/python2.4
code compilation:
installation (/opt/python2.4)
Bookmarks