pyversions fails after update-alternatives
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-central (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: python-central
Bug found in package python-central:
% apt-cache policy python-central
python-central:
Installed: 0.6.15ubuntu2
Candidate: 0.6.15ubuntu2
Version table:
*** 0.6.15ubuntu2 0
500 http://
100 /var/lib/
% lsb_release -rd
Description: Ubuntu 10.10
Release: 10.10
If one uses the standard Debian facility update-alternatives to set up alternatives for python, then calls to pyversions (or to any pycentral function that uses pyversions) will fail. E.g.:
% sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 20
...
% sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
...
% which python
/usr/bin/python
% readlink -e $(which python)
/usr/bin/python2.6
% pyversions -vd
pyversions: /usr/bin/python does not match the python default version. It must be reset to point to python2.6
The reason is that pyversion uses os.readlink to determine the actual executable that /usr/bin/python points to,
but readlink only follows one symlink, which means that it will not return the desired value if the first symlink
points to another symlink, as is the case after running update-alternatives as shown above:
% readlink $(which python)
/etc/alternativ
% readlink $(readlink $(which python))
/usr/bin/python2.6
The solution is simple: just change the call to os.readlink in pyversions to os.path.realpath.
This bug was present in both /usr/share/
you are not supposed to change the python symlink. hardly anything is ready for python2.7 in maverick