What are the packages/libraries I should install before compiling Python from source?
Posted
by
Lennart Regebro
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Lennart Regebro
Published on 2011-01-14T18:14:02Z
Indexed on
2011/11/29
18:03 UTC
Read the original article
Hit count: 408
Once in a while I need to install a new Ubuntu (I used it both for desktop and servers) and I always forget a couple of libraries I should have installed before compiling, meaning I have to recompile, and it's getting annoying.
So now I want to make a complete list of all library packages to install before compiling Python (and preferably how optional they are).
This is the list I compiled with below help and by digging in setup.py
. It is complete for Ubuntu 10.04 and 11.04 at least:
build-essential (obviously)
libz-dev (also pretty common and essential)
libreadline-dev (or the Python prompt is crap)
libncursesw5-dev
libssl-dev
libgdbm-dev
libsqlite3-dev
libbz2-dev
More optional:
tk-dev
libdb-dev
Ubuntu has no packages for v1.8.5 of the Berkeley database, nor (for obvious reasons) the Sun audio hardware, so the bsddb185
and sunaudiodev
modules will still not be built on Ubuntu, but all other modules are built with the above packages installed.
Python 2.5 and Python 2.6 also needs to have LDFLAGS set on Ubuntu 11.04 and later, to handle the new multi-arch layout:
export LDFLAGS="-L/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
For Python 2.6 and 2.7 you also need to explicitly enable SSL after running the ./configure
script and before running make
. In Modules/Setup
there are lines like this:
#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto
Uncomment these lines and change the SSL variable to /usr
:
SSL=/usr
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
Python 2.6 also needs Modules/_ssl.c modified to be used with OpenSSL 1.0, which is used in Ubuntu 11.10. At around line 300 you'll find this:
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_SSL23)
self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
Change that into:
else if (proto_version == PY_SSL_VERSION_SSL3)
self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
#ifndef OPENSSL_NO_SSL2
else if (proto_version == PY_SSL_VERSION_SSL2)
self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
#endif
else if (proto_version == PY_SSL_VERSION_SSL23)
self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
This disables SSL_v2 support, which apparently is gone in OpenSSL1.0.
© Ask Ubuntu or respective owner