Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange Python compilation results with "--enable-shared" flag

I am using Debian (which comes with Python-2.7.3), trying to compile Python-2.7.6 from source for use with mod_wsgi alongside Apache.

Apparently you must use --enable-shared when compiling for mod_wsgi usage, according to numerous answers.

Following these steps:

./configure --enable-shared --prefix=/usr/local/bin/python-2.7.6
make
make install

And then checking the interactive shell @

/usr/local/bin/python-2.7.6/bin/python

I am greeted with "Python 2.7.3 (default, Jan 2 2013, 14:09:21)" etc

Why is it resulting in Python 2.7.3?

I tried ldd against the executable and this is the result:

linux-vdso.so.1 =>  (0x00007fff271ff000)
libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007f1545638000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f154541c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1545217000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f1545014000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1544d92000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1544a06000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f15447ef000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f15445d9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1545b40000)

How do I stop it from using the system library and instead use the locally compiled version?

I know that it is a lot easier for me to just revert to using the system installed Python version, and that the real-world difference is zero. But this behaviour seems strange.

like image 617
Chris Berry Avatar asked Mar 03 '14 20:03

Chris Berry


1 Answers

When you do the make of Python, run it as:

LD_RUN_PATH=/usr/local/lib make

Setting the environment variable LD_RUN_PATH forces 'python' executable generated to look in /usr/local/lib before /usr/lib for Python shared library.

This is mentioned in the mod_wsgi documentation.

  • http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library

Before doing this again, make sure you do a 'make distclean' and rerun configure to make sure you haven't got old build products around.

like image 76
Graham Dumpleton Avatar answered Sep 28 '22 12:09

Graham Dumpleton