Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does ./configure --enable-shared do during python altinstall?

When I altinstall python 2.7.12 with

./configure --prefix=/opt/python --enable-shared

it comes up as python 2.7.5 (system default python)

But without

--enable-shared

it comes up as 2.7.12, what am I missing?

This is on RHEL 7.2


This is not a pathing issue:

Without --enable-shared

[root@myrig ~]# /opt/python/bin/python2.7 -V

Python 2.7.12

With --enable-shared

[root@myrig ~]# /opt/python/bin/python2.7 -V

Python 2.7.5

like image 864
Hec Avatar asked Aug 04 '16 16:08

Hec


People also ask

What is enable shared?

The -enable-shared option ensures to build both static and dynamic Python libraries. This option is mandatory for a correct behaviour of the Gildas-Python binding. The -prefix option allows you to install Python in a custom location (instead of /usr/local).

What does enable optimizations do Python?

@NathanielFord It's the build time for Python itself that's slowed down by enabling the optimizations. Most source builds are debug ones for development purposes, so the default config settings favour faster binary builds at the expense of slightly slower test case execution times.

What is configure Python?

The Python Configuration can be used to build a customized Python which behaves as the regular Python. For example, environment variables and command line arguments are used to configure Python. The Isolated Configuration can be used to embed Python into an application.


2 Answers

Compiling python like this fixed my issue:

./configure --enable-shared --prefix=/opt/python LDFLAGS=-Wl,-rpath=/opt/python/lib

Courtesy Ned Deily:

The problem is, that on most Unix systems (with the notable exception of Mac OS X), the path to shared libraries is not an absolute path. So, if you install Python in a non-standard location, which is the right thing to do so as not to interfere with a system Python of the same version, you will need to configure in the path to the shared library or supply it via an environment variable at run time, like LD_LIBRARY_PATH. You may be better off avoiding --enable-shared; it's easy to run into problems like this with it.

Ref: https://bugs.python.org/issue27685

like image 79
Hec Avatar answered Oct 17 '22 08:10

Hec


I'm not sure why the version number is different, but Graham Dumpleton says at this website that "When running configure, you should be supplying the --enable-shared option to ensure that shared libraries are built for Python. By not doing this you are preventing any application which wants to use Python as an embedded environment from working."

like image 22
Runner Avatar answered Oct 17 '22 09:10

Runner