[Python-bugs-list] [Bug #114758] sys.prefix can be wrong with multiple Python installations
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 18 Sep 2000 19:15:52 -0700
Bug #114758, was updated on 2000-Sep-18 17:19
Here is a current snapshot of the bug.
Project: Python
Category: Core
Status: Closed
Resolution: Wont Fix
Bug Group: None
Priority: 5
Summary: sys.prefix can be wrong with multiple Python installations
Details: When installations of the same Python version are present on the same machine, sys.prefix (and exec_prefix) can be computed incorrectly for some of them under certain circumstances. Specifically, if all the following are true:
* Python A was installed with prefix != exec-prefix
* Python B's interpreter binary precede's Python A's
binary in PATH
Then Python A computes sys.prefix wrong: it gets Python B's prefix.
Specific example: I have 2.0cvs installed with
--prefix=/usr/local/python
--exec-prefix=/usr/local/python.linux-i86
with a symlink /usr/local/bin/python2.0cvs pointing to /usr/local/python.linux-i86/bin/python2.0.
I also have the BeOpen Python 2.0b1 RPM installed, so /usr/local/bin/python is the BeOpen build.
Whether I run the CVS version as "/usr/local/bin/python2.0cvs" or as "/usr/local/python.linux-i86/bin/python", it gets sys.prefix wrong:
$ /usr/local/bin/python2.0cvs -c "import sys ; print sys.prefix ; print sys.exec_prefix"
/usr/local/bin/..
/usr/local/bin/../python.linux-i86
$ /usr/local/python.linux-i86/bin/python -c "import sys ; print sys.prefix ; print sys.exec_prefix"
/usr/local
/usr/local/python.linux-i86
Hmm, it does get exec_prefix right.
Follow-Ups:
Date: 2000-Sep-18 19:15
By: gvanrossum
Comment:
This is because of some (CNRI depot-inspired!) assumptions for finding the prefix landmark when prefix!=exec_prefix. I don't think it's worth fixing.
Interpreter A is first looking for its prefix landmark (os.py) relative to its binary's location by stripping off more and more trailing directories. It thus probes the sequence (I think):
1. /usr/local/python.linux-i86/bin/lib/python2.0/os.py
2. /usr/local/python.linux-i86/lib/python2.0/os.py
3. /usr/local/lib/python2.0/os.py
And lo and behold, that's interpreter B's landmark!
I can't change the search algorithm to use the compiled-in default prefix *before* probing the path: the path probe is intended to detect that Python was installed in a different directory than its default prefix!
An easy solution for you is to make sure that prefix is a parent dir of exec_prefix.
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=114758&group_id=5470