Installation Issue : Dangling symlink six and decorator

Bug #1533634 reported by Himanshu Mishra
60
This bug affects 18 people
Affects Status Importance Assigned to Milestone
python-pip (Debian)
Fix Released
Unknown
python-pip (Ubuntu)
Fix Released
Undecided
Unassigned
python-scipy (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

This might be a user specific bug but this is what happened with me.

I installed `python-scipy` using apt-get on ubuntu. While using `scikit-image` I had to import the module `scipy.lib.six` and then I got `No module named six`. But I had already installed `six`. So, I did some lookups and came to know that while installing, scipy creates a symlink to the `six` module inside `scipy.lib`. And that's how `scipy.lib.six` import works. But there's a catch. The symlink is created as _`../../six.py`_.

Here the issue can get user-specific. For me, six was installed inside `/usr/local/lib/python-2.7/dist-packages/` and scipy inside `/usr/lib/python-2.7/dist-packages/`. Note the `/local`. So, scipy was not able to find any `../../six.py`, that's what the issue is about. Same goes for `scipy.lib.decorator`.

If this is considered as a bug, possible solutions which I can think of is :

1. **Complete module import inside `scipy.lib.six`**

  Having a wildcard import of the six module.
  We can also have a try/catch block to raise a custom exception.

2. **Create a symlink after locating the module**

  ```python
  In [1]: import six

  In [2]: six.__file__
  Out[2]: '/usr/local/lib/python2.7/dist-packages/six.pyc'
  ```

**Same goes for `decorator`.**

Revision history for this message
Julian Taylor (jtaylor) wrote :

scipy depends on python-six and python-decorator so it should have also been present in /usr/lib/python-2.7/dist-packages/ and found.
Are these files present on your system?

I cannot reproduce the issue even when I put a six into /usr/local

note newer versions of the scipy package only symlink decorator, six is now an embedded copy as it contains some patches.

Revision history for this message
Peter Tripp (notpeter) wrote :

As far as I'm concerned this is a packaging bug plain and simple. There's no reason to have the python-scipy package depend upon python-decorator/python3-decorator with a fragile symlink.

Upstream scipy 0.17.0 does not symlink decorator.py it vendors a working copy:
https://github.com/scipy/scipy/blob/v0.17.0/scipy/_lib/decorator.py

jtaylor switched to a symlink ages ago (2013-05-09) in debian upstream python-scipy 0.12.0-1
https://launchpad.net/debian/+source/python-scipy/0.12.0-1

I understand the logic behind that change and while there's nothing in the Debian Python Packaging guide which explicitly forbids it, making a symlink to a file provided by another package strikes me as extremely poor form. Personally I'd vote for re-including the copy decorator.py included upstream. Alternatively a simple "from decorator import *" in decorator.py would be similarly as kludgy but without a guaranteed broken scipy when pip uninstalls the system decorator.

Thoughts jtaylor?

----

Steps to reproduce:

pip install a package which has a dependency on any version of decorator newer than the 4.0.6 provided by python-decorator. Pip will happily uninstall it from the old location (/usr/lib/python3/dist-packages) and install the newer version in an alternate location (/usr/local/lib/python3.5/dist-packages/ for me) which breaks the symlink.

For googlability when running import scipy._lib.decorator the error is:
ImportError: No module named 'scipy._lib.decorator'

Revision history for this message
Matthias Klose (doko) wrote :

> when pip uninstalls the system decorator

yes, that's the issue here. pip should not touch files which it doesn't handle. Is this still not fixed?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-pip (Ubuntu):
status: New → Confirmed
Changed in python-scipy (Ubuntu):
status: New → Confirmed
Revision history for this message
Kai Kasurinen (kai-kasurinen) wrote :

Fixed in version python-pip/1.5.6-4

python-pip (1.5.6-4) unstable; urgency=medium
...
 * Add patch (reviewed by upstream, but not commited there yet) to prevent
     pip from removing system python packages (Closes: #771794)

Changed in python-pip (Ubuntu):
status: Confirmed → Fix Released
Changed in python-scipy (Ubuntu):
status: Confirmed → Invalid
Changed in python-pip (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.