This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: configured libdir not correctly passed to Python executable
Type: Stage:
Components: Build, Installation Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jeffrey.Kintscher, michael-o, vstinner
Priority: normal Keywords:

Created on 2019-04-30 11:15 by michael-o, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg341148 - (view) Author: Michael Osipov (michael-o) * Date: 2019-04-30 11:15
I do compile Python from master on HP-UX with aCC:

# echo $LDFLAGS $CPPFLAGS
-L/opt/ports/lib/hpux32 -I/opt/ports/include
UNIX_STD=1998 LDFLAGS="$LDFLAGS -lreadline" CPPFLAGS="-I$PREFIX/include/ncurses $CPPFLAGS" ./configure --prefix=/opt/python \
  --libdir=/opt/python/lib/hpux32 --with-system-expat --with-openssl=/opt/openssl

having libs in hpux32 or hpux64 is a convention on this platform. When Python is installed the following happens:

$ /opt/python/bin/python3
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python 3.8.0a3+ (default, Apr 30 2019, 12:09:29) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/opt/python/lib/python38.zip', '/opt/python/lib/python3.8', '/opt/python/lib/lib-dynload', '/net/home/osipovmi/.local/lib/python3.8/site-packages', '/opt/python/lib/python3.8/site-packages']

I don't see hpux32 anywhere here. Though all shared objects are there.

Reconfiguring:

# echo $LDFLAGS $CPPFLAGS
-L/opt/ports/lib/hpux32 -I/opt/ports/include
UNIX_STD=1998 LDFLAGS="$LDFLAGS -lreadline" CPPFLAGS="-I$PREFIX/include/ncurses $CPPFLAGS" ./configure --prefix=/opt/python \
  --with-system-expat --with-openssl=/opt/openssl

gives me the expected result:
$ /opt/python/bin/python3
Python 3.8.0a3+ (default, Apr 30 2019, 12:21:15) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/opt/python/lib/python38.zip', '/opt/python/lib/python3.8', '/opt/python/lib/python3.8/lib-dynload', '/net/home/osipovmi/.local/lib/python3.8/site-packages', '/opt/python/lib/python3.8/site-packages']
>>>

It pretty much seems like '--libdir' is not correctly passed down to the installation.

I can see that at least this is wrong:
./Lib/distutils/tests/test_install.py:59:        libdir = os.path.join(destination, "lib", "python")
./Lib/distutils/command/install.py:32:        'purelib': '$base/lib/python$py_version_short/site-packages',
./Lib/distutils/command/install.py:33:        'platlib': '$platbase/lib/python$py_version_short/site-packages',
./Lib/distutils/command/install.py:39:        'purelib': '$base/lib/python',
./Lib/distutils/command/install.py:40:        'platlib': '$base/lib/python',
./Lib/sysconfig.py:23:        'stdlib': '{installed_base}/lib/python{py_version_short}',
./Lib/sysconfig.py:24:        'platstdlib': '{platbase}/lib/python{py_version_short}',
./Lib/sysconfig.py:25:        'purelib': '{base}/lib/python{py_version_short}/site-packages',
./Lib/sysconfig.py:26:        'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
./Lib/sysconfig.py:35:        'stdlib': '{installed_base}/lib/python',
./Lib/sysconfig.py:36:        'platstdlib': '{base}/lib/python',
./Lib/sysconfig.py:37:        'purelib': '{base}/lib/python',
./Lib/sysconfig.py:38:        'platlib': '{base}/lib/python',
./Lib/sysconfig.py:65:        'stdlib': '{userbase}/lib/python{py_version_short}',
./Lib/sysconfig.py:66:        'platstdlib': '{userbase}/lib/python{py_version_short}',
./Lib/sysconfig.py:67:        'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
./Lib/sysconfig.py:68:        'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
./Lib/sysconfig.py:74:        'stdlib': '{userbase}/lib/python',
./Lib/sysconfig.py:75:        'platstdlib': '{userbase}/lib/python',
./Lib/sysconfig.py:76:        'purelib': '{userbase}/lib/python/site-packages',
./Lib/sysconfig.py:77:        'platlib': '{userbase}/lib/python/site-packages',
./configure.ac:4653:  LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
./Misc/python-config.sh.in:50:LIBDEST=${prefix_real}/lib/python${VERSION}
./Modules/getpath.c:129:    wchar_t *lib_python;               /* "lib/pythonX.Y" */
./Modules/getpath.c:131:    wchar_t zip_path[MAXPATHLEN+1];    /* ".../lib/pythonXY.zip" */
./Modules/getpath.c:520:     * e.g. /usr/local/lib/python1.5 is reduced to /usr/local.
./Modules/getpath.c:1018:    err = joinpath(calculate->zip_path, L"lib/python00.zip", zip_path_len);
./Modules/getpath.c:1147:    calculate->lib_python = Py_DecodeLocale("lib/python" VERSION, &len);
./Python/coreconfig.c:103:#  define PYTHONHOMEHELP "<prefix>/lib/pythonX.X"


I have changed those files manually by adding '/hpux32' everywhere and ran configure with custom libdir:
no avail. 'lib/python' will still be used. If this cannot be changed, a warning should be issued with ./configure that custom libdir will lead to loading issues.
msg341354 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2019-05-03 19:34
I can reproduce the problem.

The Makefile uses LIBDIR as set by configure to install the libraries and this is not consistent with Modules/getpath.c that finds the locations of the libraries (see the detailed comments at the top of the source file) without searching for LIBDIR.

The work around is to use PYTHONHOME.
Michael is right and ./configure should at least issue a warning when --libdir is used.
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80939
2019-12-10 07:51:18xdegayesetnosy: - xdegaye
2019-05-22 10:11:44Jeffrey.Kintschersetnosy: + Jeffrey.Kintscher
2019-05-03 19:34:02xdegayesetnosy: + xdegaye
messages: + msg341354
2019-04-30 11:15:48michael-ocreate