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: python v3.5.1: sys.paths not respecting DESTDIRS and DESTSHARED
Type: behavior Stage:
Components: Installation Versions: Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jojo, ned.deily, yaro-yaro
Priority: normal Keywords:

Created on 2016-05-07 13:41 by yaro-yaro, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
_sysconfigdata.py yaro-yaro, 2016-05-07 13:41 system & installation configuration
Messages (13)
msg265069 - (view) Author: Jaroslav Urban (yaro-yaro) Date: 2016-05-07 13:41
#wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz
#xz -d Python-3.5.1.tar.xz
#tar xvf Python-3.5.1.tar
#cd Python-3.5.1
#./configure --prefix=/usr
#make
#make altinstall

-----------------------------------

so far so good

but afterwards

$python3.5
>>>import base64

results in

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/base64.py", line 10, in <module>
    import struct
  File "/usr/lib/python3.5/struct.py", line 13, in <module>
    from _struct import *
ImportError: No module named '_struct'

------------------------------------------

>>>import sys
>>>sys.path
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-linux', '/usr/lib/lib-dynload', '/usr/lib/python3.5/site-packages']

------------------------------------------

this path is wrong '/usr/lib/lib-dynload'
correctly it should point to the '/usr/lib64/python3.5/lib-dynload' as per the destination folders generated and used via configure / make / make altinstall

thank you
yaro-yaro
msg265071 - (view) Author: Jaroslav Urban (yaro-yaro) Date: 2016-05-07 14:24
just a remark, my system is

$uname -r
4.4.5-200.fc22.x86_64

and these python-related rpm archives are installed:

$rpm -qa | grep python
python-IPy-0.81-12.fc22.noarch
python-urllib3-1.13.1-3.fc22.noarch
libselinux-python-2.3-10.fc22.x86_64
python-kitchen-1.2.1-2.fc22.noarch
python-backports-1.0-5.fc22.x86_64
python3-gobject-3.16.2-1.fc22.x86_64
python3-slip-dbus-0.6.4-1.fc22.noarch
python-meh-0.40-1.fc22.noarch
python3-dbus-1.2.0-7.fc22.x86_64
python3-PyXB-1.2.4-2.fc22.noarch
python-augeas-0.5.0-2.fc22.noarch
python-libcomps-0.1.6-14.fc22.x86_64
python-libs-2.7.10-8.fc22.x86_64
python-pwquality-1.2.4-3.fc22.x86_64
libsemanage-python-2.3-6.fc22.x86_64
python-di-0.3-4.fc21.noarch
python3-requests-2.9.1-1.fc22.noarch
libxml2-python-2.9.3-1.fc22.x86_64
audit-libs-python-2.4.5-1.fc22.x86_64
python-dnf-langpacks-0.15.1-1.fc22.noarch
python-talloc-2.1.5-2.fc22.x86_64
python-pexpect-3.1-3.fc21.noarch
python-pip-6.0.8-1.fc22.noarch
python3-libs-3.4.2-6.fc22.x86_64
python3-cups-1.9.72-1.fc22.x86_64
python3-pycurl-7.19.5.1-3.fc22.x86_64
python-dnf-1.1.6-2.fc22.noarch
python3-humanize-0.5.1-1.fc22.noarch
python3-pip-6.0.8-1.fc22.noarch
python3-cairo-1.10.0-11.fc22.x86_64
python-blivet-1.0.10-1.fc22.noarch
python3-lxml-3.3.6-1.fc22.x86_64
python-pyudev-0.16.1-3.fc22.noarch
python-iniparse-0.4-15.fc22.noarch
python3-enchant-1.6.6-1.fc22.noarch
python3-systemd-231-4.fc22.x86_64
python3-urllib3-1.13.1-3.fc22.noarch
python-2.7.10-8.fc22.x86_64
python-coverage-4.0.3-1.fc22.x86_64
python-slip-0.6.4-1.fc22.noarch
python3-firewall-0.3.14.2-4.fc22.noarch
python3-sssdconfig-1.13.3-5.fc22.noarch
python-hawkey-0.6.2-2.fc22.x86_64
python2-pyparsing-2.1.0-2.fc22.noarch
python-xpyb-1.3.1-4.fc22.x86_64
python-setuptools-17.1.1-3.fc22.noarch
python3-setuptools-17.1.1-3.fc22.noarch
python-pycurl-7.19.5.1-3.fc22.x86_64
python-six-1.9.0-1.fc22.noarch
python-decorator-3.4.0-5.fc21.noarch
python-dmidecode-3.10.13-12.fc22.x86_64
python2-systemd-231-4.fc22.x86_64
python-requests-2.9.1-1.fc22.noarch
python-backports-ssl_match_hostname-3.5.0.1-1.fc22.noarch
policycoreutils-python-2.3-18.fc22.x86_64
python-slip-dbus-0.6.4-1.fc22.noarch
python-librepo-1.7.16-1.fc22.x86_64
langtable-python-0.0.34-1.fc22.noarch
python-firewall-0.3.14.2-4.fc22.noarch
python-chardet-2.2.1-2.fc22.noarch
python3-six-1.9.0-1.fc22.noarch
python3-chardet-2.2.1-2.fc22.noarch
python-meh-gui-0.40-1.fc22.noarch
libuser-python-0.62-1.fc22.x86_64
libselinux-python3-2.3-10.fc22.x86_64
libreport-python3-2.6.4-1.fc22.x86_64
python-urlgrabber-3.10.1-6.fc22.noarch
python-dnf-plugins-extras-common-0.0.11-1.fc22.noarch
python3-inotify-0.9.6-1.fc22.noarch
python3-slip-0.6.4-1.fc22.noarch
newt-python-0.52.18-1.fc22.x86_64
python-ntplib-0.3.2-3.fc21.noarch
dbus-python-1.2.0-7.fc22.x86_64
python3-decorator-3.4.0-5.fc21.noarch
rpm-python-4.12.0.1-14.fc22.x86_64
libreport-python-2.6.4-1.fc22.x86_64
python3-javapackages-4.3.2-6.fc22.noarch
python-sssdconfig-1.13.3-5.fc22.noarch
python3-3.4.2-6.fc22.x86_64
python-dnf-plugins-core-0.1.16-1.fc22.noarch
python-dnf-plugins-extras-migrate-0.0.11-1.fc22.noarch
python3-cssselect-0.9.1-5.fc22.noarch
msg266056 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-05-22 06:44
Sorry, I'm not able to reproduce your results on a vanilla Debian system.  Building from scratch with ./configure --prefix=/usr and make steps results in:

$ /usr/bin/python3.5
Python 3.5.1 (default, May 22 2016, 02:26:09)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> import sys, _struct
>>> _struct.__file__
'/usr/lib/python3.5/lib-dynload/_struct.cpython-35m-x86_64-linux-gnu.so'
>>> sys.path
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-linux', '/usr/lib/python3.5/lib-dynload', '/home/sysadmin/.local/lib/python3.5/site-packages', '/usr/lib/python3.5/site-packages']
>>>

Is it possible you had a virtual environment in effect?  Try repeating with "/usr/bin/python3.5" and verifying the build timestamp.  As far as I know, an unpatched Python 3.5 will not attempt to install anything into /usr/lib64 by default.
msg266198 - (view) Author: Johannes S. (jojo) Date: 2016-05-23 22:15
I can confirm this issue. I did run it on Linux SuSE 13.1 (64 Bit). Unlike other components, which are installed in `lib/`, `lib-dynload` is installed in `lib64/python3.5/`. But `sys.path` still points to `lib/python3.5/lib-dynload`. It did run in on :

mkdir build
cd build
../configure --prefix="${HOME}/.opt"
nice -n 19 make -j 6
make install
msg266223 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-05-24 04:02
That's very odd!  I don't have a SuSE system available to test with but it is not clear to me why that would have different behavior because where the standard library extension modules directory (lib-dynload) is installed is controlled by the Python configure and Makefile and, in the vanilla copies downloadable from python.org, I can't find any relevant references to lib64 (there are some in setup.py as far as where to look for linking with other library files).  Are you sure you are using an unpatched 3.5.1 source tarball downloaded from python.org?  And that any lib-dynload in /lib64 wasn't installed by SuSE?  When I follow the steps you give, I end up with the extension modules in ~/.opt/lib/python3.5/lib-dynload as expected.  I don't know what else to suggest.  Anyone else have any ideas?
msg266237 - (view) Author: Johannes S. (jojo) Date: 2016-05-24 07:12
I tried it again and I also tried 3.6.0a1 now. 3.6.0a1 has the issue as well. I have downloaded the tarballs from https://www.python.org/downloads/release/python-351/ and https://www.python.org/downloads/release/python-360a1/.

I have run it on my Laptop (Arch Linux) now. The issue did *not* occur there. But I discovered that I can trigger a similar issue by specifying the libdir explicitly with

    `../configure --prefix="/some/dir" --libdir="/some/dir/lib64"`.

I thing it would be reasonable to assume that both issues are related.
msg267453 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-06-05 18:34
Sorry, it is no longer clear to me exactly what problem(s) and solution are being proposed here.  When dealing with installation problems like this, we have to be *very* precise: here's what I started with on what platform, here are the contents of the relevant directories and/or files before I start, here are exactly the steps I took, here are the results I expected, and here are the results I observed.  Using a downloaded tarball and the steps in @yaro-yaro's initial message, I see no change in /usr/lib64; note, there *may* have been Python .so files installed there by system packages but that should be irrelevant to building and installing your own Python.  I also could not reproduce @jojo's recipe as best I understand it and don't see how it could produce any change in /usr/lib64.  Changing the value of --libdir is a whole different matter and not relevant to the original problem.  Also the title of the issue refers to DESTDIR and DESTSHARED but nowhere in the body of the issue are these variables directly referenced, so I have to assume they aren't being explicitly set.

Unless someone can better demonstrate an actual problem here, I'm going to close this issue.
msg268856 - (view) Author: Johannes S. (jojo) Date: 2016-06-19 16:48
Maybe my last comment was not clear enogth. I used the tarballs from 3.5 and 3.6 which are linked in my last comment. I extracted them and run the the following commands on Arch (64 Bit) and Linux SuSE 13.1 (64 Bit):

    mkdir build
    cd build
    ../configure --prefix=/some/dir
    make
    make install

The path `/some/dir` is a placeholder. The path did not exist before running this commands. After running them on Linux SuSE, I discovered that `libpython3.5m.a`, `pkgconfig/` and `python3.5/lib-dynload` was placed in `/some/dir/lib64` instead of `/some/dir/lib`. On Arch, everything is placed in `/some/dir/lib` but I have the same behavior if I add `--libdir=/some/dir/lib64` to `configure`. With other words: `--libdir` seems to have a default value of "EPREFIX/lib64" instead of "EPREFIX/lib" on my instance of Linux SuSE. Maybe `configure` uses some global configurations here?

The problem is, that `sys.path` does point to `/some/dir/lib/lib-dynload` in all cases described above. Since `python3.5/lib-dynload` may be placed in `lib64`, this may cause that python does not run properly after installing it.

(Unfortunately, I cannot say much about the configuration of "my instance of Linux SuSE" since I am not the person who set it up. It is a server of my university.)
msg269427 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-06-28 09:14
Johannes, what are the values of CONFIG_ARGS and libdir in the config.log of your Linux SuSE.
msg274075 - (view) Author: Johannes S. (jojo) Date: 2016-08-31 21:48
Sorry that I haven't answered for a long time. I would like to get an email notification but I don't know whether/how I can enable it.

On "my instance of Linux SuSE", the lines are locking like this:

CONFIG_ARGS=' '\''--prefix=/some/dir'\'''
libdir='${exec_prefix}/lib64'
msg275002 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-09-08 11:45
> Sorry that I haven't answered for a long time. I would like to get an email notification but I don't know whether/how I can enable it.

You should get an email upon each message posted to this issue. The email is sent to the address you have registered with as "jojo".


So your config.log confirms that the configure script does use ${exec_prefix}/lib64.
Your system may be configured with a configure system-wide initialization file [1]. In that case, configure will print a line starting with:
    "loading site script ..."
and showing the path to the config.site file that is being loaded. As described at the end of [1], this is where libdir may be set to '${exec_prefix}/lib64'.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Site-Defaults.html
msg275316 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-09-09 13:57
The problem can be reproduced as follows:

Run the following commands to install python with a site configuration file that installs the libraries to lib64:

  export INSTALL_DIR=/some/path/to/install
  mkdir -p $INSTALL_DIR/share
  echo "test \"\$libdir\" = '\${exec_prefix}/lib' && libdir='\${exec_prefix}/lib64'" > $INSTALL_DIR/share/config.site
  ./configure --prefix=$INSTALL_DIR && make install

Check that the libraries have been installed to lib64 and that python fails to find them:

$ find $INSTALL_DIR -name lib-dynload
/some/path/to/install/lib64/python3.6/lib-dynload

$ $INSTALL_DIR/bin/python3 -E
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python 3.6.0a4+ (default:98a57845c8cc, Sep  9 2016, 15:34:27) 
[GCC 6.1.1 20160707] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/some/path/to/install/lib/python3.6/base64.py", line 10, in <module>
    import struct
  File "/some/path/to/install/lib/python3.6/struct.py", line 13, in <module>
    from _struct import *
ModuleNotFoundError: No module named '_struct'
>>>
msg275319 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-09-09 14:47
The problem is that Makefile and Modules/getpath.c are not consistent:
* Makefile uses $(LIBDIR)/python$(VERSION)/lib-dynload as the location of the installed shared libraries and in this issue, it happens that LIBDIR is not ${exec_prefix}/lib but is ${exec_prefix}/lib64 instead.
* Py_GetPath() in Modules/getpath.c uses the concatenation of EXEC_PREFIX with "lib/python", VERSION and "lib-dynload" to construct the corresponding sys.path entry when falling back to using the EXEC_PREFIX preprocessor variable.

Another problem may be that with this issue, Py_GetPath() constructs the string "/some/path/to/install/lib/lib-dynload" missing entirely the python$(VERSION) component part (as shown by sys.path in the interpreter).
History
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71158
2019-12-10 08:15:26xdegayesetnosy: - xdegaye
2016-09-09 14:47:14xdegayesetmessages: + msg275319
2016-09-09 13:57:39xdegayesetmessages: + msg275316
2016-09-08 11:45:02xdegayesetmessages: + msg275002
2016-08-31 21:48:11jojosetmessages: + msg274075
2016-06-28 09:14:23xdegayesetnosy: + xdegaye
messages: + msg269427
2016-06-19 16:48:13jojosetstatus: pending -> open

messages: + msg268856
2016-06-05 18:34:39ned.deilysetstatus: open -> pending

messages: + msg267453
2016-05-24 07:12:53jojosetmessages: + msg266237
versions: + Python 3.6
2016-05-24 04:02:37ned.deilysetmessages: + msg266223
2016-05-23 22:15:00jojosetnosy: + jojo
messages: + msg266198
2016-05-22 06:44:13ned.deilysetnosy: + ned.deily
messages: + msg266056
2016-05-07 14:25:01yaro-yarosetmessages: + msg265071
2016-05-07 13:41:21yaro-yarocreate