What does this python-config option mean? (installing python from a downloaded compressed .tgz folder)

36 Views Asked by At

I am referencing this Medium article, https://medium.com/@lupiel/installing-python-from-a-tgz-file-a-step-by-step-guide-4cf5f4a17a86, and it recommends tagging on the following option to the ./configure script when installing python on linux.

LDFLAGS=-Wl,-rpath=/opt/python/${PYTHON_VERSION}/lib,--disable-new-dtags

I've looked at the man page for python-configure and it is relatively short. I didn't find anything in python3-config --help either. It tells me that LDFLAGS "print the flags that should be passed to the linker." I read that a linker is a symlink? Regardless, this is the extent of information I've been able to find. I don't understand what the rest does.

1

There are 1 best solutions below

0
wim On

These configure options will build a shared library, which means that the Python interpreter will be contained mostly in an external libpython3.so file, and the python executable will just be a small shim (maybe 15 kb) that will link to the libpython shared object.

These LDFLAGS, combined with the --enable-shared option the article mentioned, means that the python executable will be configured with a run-time search path of /opt/python/${PYTHON_ VERSION}/lib to find this shared object, i.e. at startup time it will look for a libpython3.so file in there to dynamically link against.

This is not the default way to build CPython. By default the interpreter is burnt into the Python executable, i.e. the python exe will be much bigger (megabytes) and an external libpython3.so file will not be generated at all. Doing it this way, without --enable-shared, will result in a slightly faster and more memory-efficient build of CPython.

I do not recommend using --enable-shared, unless you specifically need it (for e.g. embedding). If you don't know what it's for, you don't need it.