giovedì 22 novembre 2012

python 2.4 and python 2.6 on ubuntu 12.10


For business reasons I am forced to use python 2.6 and python 2.4.
Compile the python on each  *buntu 12.10 machine that i have is a frustrating job. (some real, many virtual)
I made packages with checkinstall, these are not true ppa but maybe someone can find them useful.
I've also tested on Ubuntu 12.10 server and Lubuntu 12.10
First install the dependencies:

sudo apt-get install zlib1g libncurses5 libncursesw5 libc6 libbsd0 libreadline5 libreadline6 libsqlite3-0 bzip2 libgdbm3 libssl1.0.0

then download and install the packages:

sudo dpkg -i python2.6.deb
sudo dpkg -i python2.4.deb

(for now are hosted on dropbox doh!)

https://dl.dropbox.com/s/0cvh8jm7qcbq5py/python2.4.deb
https://dl.dropbox.com/s/jbdgbt2smu352ry/python2.6.deb

Everything is provided in the hope that it is useful to someone; but with no guarantee.
The paths are:

/opt/python-2.6.8/ (for python 2.6)
/opt/python-2.4.6/ (for python 2.4)

you can add to $PATH or make symlinks.

sudo ln -s /opt/python-2.4.6/bin/python2.4 /usr/bin/python2.4
sudo ln -s /opt/python-2.6.8/bin/python2.6 /usr/bin/python2.6

or even better using virtualenv, ex:

virtualenv -p /opt/python-2.6.8/bin/python --no-site-packages myenv
source myenv/bin/activate
(myenv)  ... your environment, your python, your packages.

I hope someday to have the time to create a real ppa with better packages.
The only supported architecture is i686, at least for the moment.

Build yourself!

(pre) sudo apt-get install build-essential zlib1g-dev libncurses5-dev libncursesw5-dev libc6-dev libbsd-dev libcurl4-openssl-dev libreadline-dev libreadline6-dev libsqlite3-dev libbz2-dev libgdbm-dev libssl-dev

for python 2.4.6

./configure --prefix=/opt/python-2.4.6/ --enable-unicode=ucs4 --with-ssl --without-tkinter

edit setup.py, change:

lib_dirs = self.compiler.library_dirs + [
    '/lib64', '/usr/lib64',
    '/lib', '/usr/lib',
    ]
 
to:

lib_dirs = self.compiler.library_dirs + [
'/lib64', '/usr/lib64',
'/lib', '/usr/lib', '/usr/lib/i386-linux-gnu',
]

then:

make
sudo make install

for python 2.6.8

./configure --prefix=/opt/python-2.6.8/ --enable-unicode=ucs4 --with-ssl --without-tkinter

edit setup.py, change:

lib_dirs = self.compiler.library_dirs + [
    '/lib64', '/usr/lib64',
    '/lib', '/usr/lib',
    ]
 
to:

lib_dirs = self.compiler.library_dirs + [
'/lib64', '/usr/lib64',
'/lib', '/usr/lib', '/usr/lib/i386-linux-gnu',
]

edit Modules/Setup, change:

#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto

to:

SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

edit Modules/_ssl.c, change:

  else if (proto_version == PY_SSL_VERSION_SSL2)
        self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */

to:

#ifndef OPENSSL_NO_SSL2
    else if (proto_version == PY_SSL_VERSION_SSL2)
        self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
#endif

then:

make
sudo make install

.....
good luck ;-)

TODO:

* find a better host
* a better english page
* an italian page
* more testing
* more check on deps
* 64bit version
* real package for ppa in chroot env

any help is appreciated. (thanks to Riccardo Lemmi for helping me on python, even at impossible hours.)

3 commenti:

Anonimo ha detto...

Ciao ho ricompilato senza modificare i sorgenti da lubuntu 12.10 con il comando
* ./configure --prefix=/opt/python-2.6.8/ --enable-unicode=ucs4
se ti servono i binari per 64 bit te li posso passare. Grazie e ciao.

mva ha detto...

Hi,

I've tried your method but at the end of the make I get:

Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_hashlib _sqlite3 _ssl
_tkinter bsddb185 bz2
dbm dl gdbm
imageop linuxaudiodev ossaudiodev
readline sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


Failed to build these modules:
crypt nis


So, importing hashlib fails.

Any ideas?

Manu.

mva ha detto...

Solution is in AskUbuntu: http://askubuntu.com/questions/21547/what-are-the-packages-libraries-i-should-install-before-compiling-python-from-so